I am not the biggest fan of having to use a ton of plugins with an editor and i like my Vim somewhat tidy and vanilla. Yet there are plugins i don't want to miss. But the idea of having an extra package manager, just for my Vim plugins, didn't really appeal to me. When Vim version 8 came out, i was pretty happy to hear that they had added a native and simple way to add plugins to your Vim setup. You basically just have to drop them into a subdirectory called `pack` of your `.vim` directory. Since my Vim configuration lived in git, i decided to simply add my plugins via git submodules.
As mentioned above the new plugin feature expects your plugins to live in `.vim/pack`. In there you can create subdirectories to sort the plugins to your liking. In those subdirectories, you can put your plugins either in a directory called `start` or `opt`. Plugins that live in `start` will be loaded on startup and the plugins in `opt` can be manually loaded with the `:packadd` command.
I have created the following subdirectories.
So airline, for example, which i want to have on startup lives in `.vim/pack/dist/start/airline`.
To add a plugin, you simply can add it as a submodule to your Vim configuration git repository. As an example, i just added the Vim plugin that adds support for the hy programming language to my Vim setup. I did that with a simple:
git submodule add https://github.com/hylang/vim-hy.git vim/pack/lang/start/hy
I put the plugin into the `pack/lang/start` directory, since i created `lang` for language plugins and want the plugin to be loaded on startup, so i don't have to do a `:packadd hy` everytime i need it.
Updating all your plugins is pretty simple. Just run:
git submodule update --remote --merge
This will pull the latest changes from the tracked branch, update the referenced commit and merge them into the local checkout.
Don't forget to add a commit(and push) your Vim configuration repo, since updating submodules is a change.
To remove a plugin use `git rm` on the submodules path. git will automatically detect, that inside the directory lives a submodule and also remove all references to it.
---
Back to the main page