My working process is based on the ability to override config with ability to add and configure plug-ins from the local directory _~/.vim_local_.
example with pathogen:
$ cat .vimrc
...
" add ~/.vim/bundle/** and ~/.vim_local/bundle/** to rtp
call pathogen#infect('bundle/{}','$HOME/.vim_local/bundle/{}')
...
" local config goes here
source ~/.vimrc_local
...
When i try to define two plug#begin() sections, the last section applies only. eg:
$ cat .vimrc
...
call plug#begin('$HOME/.vim/bundle')
" Plug goes here
call plug#end()
...
if !empty(glob("$HOME/.vimrc_local"))
source $HOME/.vimrc_local
endif
$ cat .vimrc_local
...
call plug#begin('$HOME/.vim_local/bundle')
" local Plug goes here
call plug#end()
...
rtp-variable contains only .vim_local/bundle/**
How can i use vim-plug for this workflow?
$ cat .vimrc
...
call plug#begin('$HOME/.vim/bundle')
" Plug goes here
...
if !empty(glob("$HOME/.vimrc_local"))
source $HOME/.vimrc_local
endif
...
call plug#end()
$ cat .vimrc_local
...
" local Plug goes here
...
You can't have two distinct bundle directories with this approach. But I don't see any reason you have to do so. Supporting multiple blocks was discussed several times in the past, but we decided that it's simply not worth it.
I am not sure if I should create a new issue for this but I am having a similar question. My workflow canters around separation of everything that is related to a certain language. Here's an example:
Right now, main.vim has to list all plugins, including clojure / python / etc related. Allowing multiple plug#begin sections would make it possible to actually list lang specific plugins in lang specific files. Excluding sourcing of a language file would then get rid of all the plugins. (e.g. removing clojure.vim from main.vim and boom! it would unload all clojure related plugins)
@dvcrn This was asked several times and we have a very clear solution to it. What's wrong with the suggested approach above? Calling plug#begin and end once in the main.vim. You're not going to use clojure.vim or python.vim alone without main.vim. Also see #425.
Yeah it's hard to search on github when everyone tends to describes issues in a different way. :)
That is how I'm having it right now, I just wasn't sure if that is the 'official' way of doing things. Thanks for the feedback!
Alright - another question related to that. I continued with deconstructing my vimrc into multiple smaller modules but ran into a similar issue.
I noticed that the trick mentioned before does not seem to work for packages that are needed right away, like styles. E.g. main.vim sources styles.vim:
" main.vim
call plug#begin('~/.vim/plugged')
source style.vim
call plug#end()
" style.vim
Plug 'chriskempson/vim-tomorrow-theme'
colorscheme Tomorrow-Night
During startup I get the error that Tomorrow-Night does not exist. After startup I can manually set it back to Tomorrow-Night though. I assume unless plug#end() is called, the plugin is not loaded yet and can not be used.
I went with defining themes inside main.vim and source style.vim after plug#end() as a workaround.
Would maybe a PostInit hook or something be a good idea for vim-plug? A callback that is executed after all packages have been loaded.
@dvcrn You can use VimEnter autocmd instead of PostInit hook.
autocmd VimEnter * colorscheme Tomorrow-Night
Ah - didn't know that. Thank you!
Most helpful comment
@dvcrn You can use VimEnter autocmd instead of
PostInithook.