ix-
ix-

Reputation: 1

Modular vimrc: how to source vundle Plugins from diffrent files

I want to break down my vimrc in diffrent components. I manage my vim Plugins with Vundle and I want to have one file per plugin that tells vundle to manage it and to set configuration like this:

vundle.vim:

set nocompatible
filetype off 
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"Plugin in here:
Plugin 'gmarik/Vundle.vim'
call vundle#end()
filetype plugin indent on
"Plugin Options:

and syntastic.vim:

set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"Plugin in here:
Plugin 'scrooloose/syntastic'
call vundle#end()
filetype plugin indent on
"Plugin Options:
" - Python:
let g:syntastic_python_checkers = ['pylint', 'flake8']
let g:syntastic_aggregate_errors = 1 

and so on.

If I now call this vimrc:

source vundle.vim
source syntastic.vim

only the last Plugin shows up in vundles Plugin list, other configurations are read though. I guess, vundle calls the 'vundle#begin()'/'vundle#end()' part only upon call (:PluginXXX) and therefore only returns the content of the file last sourced. How can I solve this problem? Can I use something like

PLUGINS = "Plugin gmarik/vundle"
PLUGINS = $PLUGINS + "Plugin scrooloose/syntastic"
...

and call

vundle#begin()
$PLUGINS
vundle#end()

in my vimrc? If so, what is the syntax for vim variables?

Upvotes: 0

Views: 1053

Answers (2)

Nomas Prime
Nomas Prime

Reputation: 1344

I ended up with this:

set nocompatible
filetype off
set rtp+=~/.nvim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'rking/ag.vim'
...
call vundle#end()
filetype plugin indent on

runtime! vundle/*.vim

Which means I get the performance of vundle#begin() and vundle#end() combined with the modularity of having settings for each plugin in their own file. This setup gave the unexpected advantage of having less plugin files to manage, i.e., the Plugin one-liners. Now the only plugin, .vim, files I have are the ones with additional configuration.

The disadvantage of this setup is I have to remove the plugin from two places.

The advantages are: increased performance; you still have fairly modular plugin settings, making them easier to add and remove.

Upvotes: 0

romainl
romainl

Reputation: 196566

~/.vimrc:

filetype off 
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

runtime! config/*.vim

call vundle#end()
filetype plugin indent on
...

~/.vim/config/syntastic.vim

Plugin 'scrooloose/syntastic'

let g:syntastic_python_checkers = ['pylint', 'flake8']
let g:syntastic_aggregate_errors = 1
...

And so on. But that's IMO a lot of work for zero benefit.

Upvotes: 1

Related Questions