Nowadays, people share even their DNA on GitHub. With such a healthy open-source ecosystem and new updates every day, here is a way to keep up with the latest versions of your vim plug-ins.
Let’s start with an idea – consider your vim configuration as project, with plug-ins as dependencies. Since you want to have the latest and greatest, you may want to directly link to their sources on github. But how? This is where git submodules come in:
git submodule add <repository> [<path>]
In the case of your vim configuration, the above command will take the following form:
git submodule add https://github.com/scrooloose/nerdtree.git .vim/bundle/nerdtree
The above command will add a reference to the project located at <repository> to your vim configuration (that is itself in git). However, there is a problem: due to the fact that many projects have their own directory structure, you cannot just add them easily to the specific directories that vim expects. Luckily, vim superstar Tim Pope has developed a remedy called “pathogen”.
This great plug-in will load other plug-ins from the ~/.vim/bundle directory. Since pathogen is yet another dependency of the project, it should be placed in the .vim/bundle folder:
git submodule add https://github.com/tpope/vim-pathogen.git .vim/bundle/pathogen
source ~/.vim/bundle/pathogen/autoload/pathogen.vim call pathogen#infect()
Now that vim is infected with the pathogen, your modules are fully loaded. Hack away!
Here comes the really sweet part: if you want to update all your plug-ins (bound by submodules), it is as sexy as running one line in bash:
git submodule foreach git pull origin master
Updating a single module is done by a
git pull origin master, if you ever need to.
I hope that this will let you manage your vim configuration with ease – it works great for me! We are one step closer to our personal configuration heaven. If you found this article to be useful, leave a comment or hit me up on twitter!