If you haven't done so already, run :help packages
in vim and read the whole section to get an understanding of how the package system works in vim.
George Ornbo also has a very good write up that explains it well.
First we need to create the directories that we will install the plugins too:
mkdir -vp $XDG_CONFIG_HOME/vim/pack/$USER/{start,opt}
If you haven't set up your vim installation to be XDG compliant, then replace $XDG_CONFIG_HOME
with ~/.vim
in the commands in this document.
Running the above command will create the following directory structure:
$XDG_CONFIG_HOME/vim/pack/
└── $USER
├── opt
└── start
Now that we have the requisite folder structure, we can install a package. If you are using git to manage your vim config, then skip down to the next section on using git submodule
.
Installing a package is just a matter of moving the package dir to the pack/start
or pack/opt
. Read :help packages
for the difference between the two.
If you're cloning a git repository, the following command will do the trick.
( set -ex
cd $XDG_CONFIG_HOME/vim/pack/$USER/start
git clone <package_repo>
vim +helptags\ ALL +quit )
If you just want to cp
the package into place, that's fine too. Just put it under pack/start/<package-name>
and don't forget to run :helptags ALL
from vim to get the help tags updated.
Note that vim may complain with something like the following when running :helptags ALL
:
E152: Cannot open /usr/share/vim/vim81/doc/tags for writing
This is just because you don't have permissions to write the tags file that would go in that directory. Don't worry though, since it's a system directory, there's probably already a tags file there and doesn't need to be updated anyway. If it bothers you, just run:silent! helptags ALL
instead, but you wont see any other warnings that may come up..
When updating the package, you can just enter the package dir and run git pull
if it's a git repository. Otherwise, just mv
the updated files into place. Don't forget to run :helptags
again in case something changed in the documentation!
( set -ex
cd $XDG_CONFIG_HOME/vim/pack/$USER/start/<package>
git pull
vim +helptags\ ALL +quit )
Removing a package is as simple as deleting the package directory and running :helptags
to update the docs.
rm -rf $XDG_CONFIG_HOME/vim/pack/$USER/start/<package> \
&& vim +helptags\ ALL +quit
TODO