From 7641665f9c122392a79e82f7f45a056ce91d4ea1 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Wed, 10 Jul 2024 08:55:07 +0200 Subject: [PATCH] Refactor plugin sets Rename plugins, plugins-noroot and plugins-noroot-nolowendbox to plugins-mini, plugins-midi and plugins-full. Rename the config functions respectively. Should make meaning of the plugin sets more clearer. Also avoid being smart on loading plugin sets based on uid or config variables. Instead provide them as plugins-xxx.vim.example and let user symlink if they shall be loaded. Also move plugins where reasonable --- README.md | 15 +++---- init.vim | 6 --- ...olowendbox.vim => plugins-full.vim.example | 3 +- plugins-local.vim.example | 2 - ...ins-noroot.vim => plugins-midi.vim.example | 4 +- plugins.vim => plugins-mini.vim | 2 +- plugsetup.vim | 39 +++++++++++-------- 7 files changed, 34 insertions(+), 37 deletions(-) rename plugins-noroot-nolowendbox.vim => plugins-full.vim.example (99%) rename plugins-noroot.vim => plugins-midi.vim.example (97%) rename plugins.vim => plugins-mini.vim (99%) diff --git a/README.md b/README.md index 43f7882..6f6760b 100644 --- a/README.md +++ b/README.md @@ -23,15 +23,12 @@ I would like to use this configuration on a large variety of machines with different needs. To accommodate for this, the configuration is split up into multiple files and a different set of plugins is used: -- In any case, the plugin set in `plugins.vim` is loaded. -- If run as non-root user, an additional plugin set in `plugins-noroot.vim` is - loaded. -- If run on a no-low-end-box, an additional plugin set in - `plugins-noroot-nolowendbox.vim` is loaded. A low-end box is indicated by the - existence of the file `lowendbox`, e.g., on my Raspberry Pi installations. -- Also, if `plugins-local.vim` exists, this plugin set is loaded, too. For - instance, on one machine I have gnupg and corresponding vim plugins - configured. +- In any case, the plugin set in `plugins-mini.vim` is loaded. +- Furthermore, `plugins-midi.vim`, `plugins-full.vim` and `plugins-local.vim` + are loaded if present. They are provided as `plugins-xxx.vim.example` and you + can create a symlink `plugins-xxx.vim` to have them loaded. (In case of + `plugins-local.vim` you will probably provide a machine-dedicated version + rather than symlinking the example file.) Similar to `plugins-local.vim`, also the following files are sourced if existent: diff --git a/init.vim b/init.vim index 9700a32..a01889a 100644 --- a/init.vim +++ b/init.vim @@ -49,12 +49,6 @@ endif syntax on -if filereadable($HOME . '/.vim/lowendbox') - let g:lowendbox = 1 -else - let g:lowendbox = 0 -endif - runtime macros.vim runtime keymaps.vim runtime plugsetup.vim diff --git a/plugins-noroot-nolowendbox.vim b/plugins-full.vim.example similarity index 99% rename from plugins-noroot-nolowendbox.vim rename to plugins-full.vim.example index f442a5d..a4095e6 100644 --- a/plugins-noroot-nolowendbox.vim +++ b/plugins-full.vim.example @@ -48,6 +48,7 @@ else endif Plug 'ryanoasis/vim-devicons', Cond(g:enable_plugin_devicons) + Plug 'joom/latex-unicoder.vim' Plug 'chrisbra/unicode.vim' @@ -70,7 +71,7 @@ if has('nvim-0.5') Plug 'nvim-treesitter/nvim-treesitter-refactor', {'do': ':TSUpdate'} endif -function PluginsNorootNolowendboxConfig() +function PluginsConfigFull() let g:neomake_c_enabled_makers = ['clangtidy', 'clangcheck'] let g:neomake_cpp_enabled_makers = ['clangtidy', 'clangcheck'] let g:clang_compilation_database = '.' diff --git a/plugins-local.vim.example b/plugins-local.vim.example index 49d6cdf..b7c7a73 100644 --- a/plugins-local.vim.example +++ b/plugins-local.vim.example @@ -1,5 +1,3 @@ -Plug 'jamessan/vim-gnupg' - "Plug 'kien/tabman.vim' "Plug 'chikamichi/mediawiki.vim' diff --git a/plugins-noroot.vim b/plugins-midi.vim.example similarity index 97% rename from plugins-noroot.vim rename to plugins-midi.vim.example index 81411f9..ca75f17 100644 --- a/plugins-noroot.vim +++ b/plugins-midi.vim.example @@ -1,5 +1,7 @@ Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} +Plug 'jamessan/vim-gnupg' + " Conditional loading does not work, see github issue #823 Plug 'ludovicchabant/vim-gutentags' "Plug 'vim-scripts/Conque-GDB', {'for': ['c', 'cpp', 'objc']} @@ -29,7 +31,7 @@ Plug 'vim-scripts/loremipsum', {'on': 'Loremipsum'} Plug 'ggandor/leap.nvim' -function PluginsNorootConfig() +function PluginsConfigMidi() let g:localvimrc_persistent = 1 let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] diff --git a/plugins.vim b/plugins-mini.vim similarity index 99% rename from plugins.vim rename to plugins-mini.vim index 66939e6..8748a31 100644 --- a/plugins.vim +++ b/plugins-mini.vim @@ -34,7 +34,7 @@ Plug 'flwyd/vim-conjoin' Plug 'nfnty/vim-nftables' -function PluginsConfig() +function PluginsConfigMini() " Some preferences for indent detection let g:detectindent_min_indent = 2 diff --git a/plugsetup.vim b/plugsetup.vim index f47a045..f34150d 100644 --- a/plugsetup.vim +++ b/plugsetup.vim @@ -9,34 +9,39 @@ endif call plug#begin('~/.vim/plugged') -source ~/.vim/plugins.vim +source ~/.vim/plugins-mini.vim " Load various conditinoal plugin sets -if filereadable($HOME . '/.vim/plugins-local.vim') - source ~/.vim/plugins-local.vim + +if filereadable($HOME . '/.vim/plugins-midi.vim') + source ~/.vim/plugins-midi.vim endif -if $USER != "root" - source ~/.vim/plugins-noroot.vim +if filereadable($HOME . '/.vim/plugins-full.vim') + source ~/.vim/plugins-full.vim +endif - if g:lowendbox == 0 - source ~/.vim/plugins-noroot-nolowendbox.vim - endif +if filereadable($HOME . '/.vim/plugins-local.vim') + source ~/.vim/plugins-local.vim endif call plug#end() -" Call the config functions of the plugins -call PluginsConfig() -if filereadable($HOME . '/.vim/plugins-local.vim') - call PluginsLocalConfig() +" Call config functions of plugin sets + +call PluginsConfigMini() + +if filereadable($HOME . '/.vim/plugins-midi.vim') + call PluginsConfigMidi() endif -if $USER != "root" - call PluginsNorootConfig() - if g:lowendbox == 0 - call PluginsNorootNolowendboxConfig() - endif + +if filereadable($HOME . '/.vim/plugins-full.vim') + call PluginsConfigFull() +endif + +if filereadable($HOME . '/.vim/plugins-local.vim') + call PluginsConfigLocal() endif -- 2.39.5