Reputation: 7632
After using vim for some time now, my ~/.vim/
beginning with my first experiments with vim got really messy over time. So I thought, it would be time to tidy up and to begin with a plugin manager with a clean configuration.
Since I share my configuration over multiple machines, I usually manage my ~/.vim/
path with a git repo. To avoid a big .vimrc, I put my own configuration under ~/.vim/plugin/
. This allowed me, to keep all my shared configuration in this folder and to use ~/.vimrc
only for machine dependent configuration.
Starting with VAM over NeoBundle and now Vundle I have always the same problem. If I add the required configuration under ~/.vim/plugin/pluginmanager.vim
instead of ~/.vimrc
, the installed plugins do not load or were only partially loaded. The command :echo &rtp
lists the correct bundles, but :scriptnames
does not include the installed plugins. If I execute mv ~/.vim/plugin/pluginmanager.vim ~/.vimrc
everythings works as expected.
Can anyone explain this behavior and perhaps offer a solution?
My pluginmanager.vim
looks like this:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'bling/vim-airline'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
My vim installation is version 7.4.52
Upvotes: 0
Views: 1080
Reputation: 172590
The problem is in the startup order. After your ~/.vimrc
has been executed (as the first thing during startup), Vim executes something like :runtime! plugin/*.vim
to load the plugins. As your plugin manager is only then invoked, the changes in the 'runtimepath'
do not reach that triggering :runtime
command any more, and the plugins fail to load.
There are many workarounds:
~/.vim/pluginmanager.vim
and explicitly :runtime pluginmanager.vim
it from (each copy of) your ~/.vimrc
.:runtime! plugin/*.vim
.But I agree with @brettanomyces that the best solution would be to use ~/.vimrc
as intended, and place system-specific configuration into a different script instead.
Upvotes: 1
Reputation: 7678
I would recommend using the ~/.vimrc
file for general configuration and having another file such as ~/.vimrc.local
with your machine specific configuration. You can source ~/.vimrc.local
by adding the following to your ~/.vimrc
.
if filereadable(glob("~/.vimrc.local"))
source ~/.vimrc.local
endif
Credit: http://blog.sanctum.geek.nz/local-vimrc-files/
To solve your issue try adding runtime! bundle/**/*.vim
to the end of your pluginmanager.vim
file.
See also: :help init
Upvotes: 1