Chicken or Egg dilemma is known from the ancient days.
In case of Vundle the dilemma manifests itself as a bunch of errors during bundles installation in certain conditions.
Problem
It’s pretty common to have settings that are plugin dependant. For instance, lets have statusline to display current git branch
, ie:
set statusline=+'%<\ %f\ %{fugitive#statusline()}'
which requires fugitive bundle auto-loadable when status line is displayed.
Having such dependency means that each time Vim
runs without fugitive - causes errors!
And it happens at least once - the very first time you try to install plugins.
This isn’t good.
Solution
The first thing that comes up on mind is to conditionally require dependants. But that’s not a clean solution as it involves bunch of if
s, which is a code smell in this case.
Instead, it’s recommended to split .vimrc
and have [Vundle]
configuration in separate file, ie:
" .vimrc
" Vundle and bundles configuration
source bundles.vim
" my configuration which depends on bundles
set statusline=+'%<\ %f\ %{fugitive#statusline()}'
and bundles.vim
:
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'tpope/vim-fugitive'
" ...rest of bundles
filetype plugin indent on " required!
That doesn’t solve our problem yet though.
What makes all the difference is the way you install bundles for the first time, like this:
$ vim -u bundles.vim +BundleInstall +qall
makes Vim
use bundles.vim
as its configuration file, run BundleInstall
and quit afterwards.
Having plugins installed makes Vim
run smoothly without any errors.
Nice!