DEV Community

Precious Chicken
Precious Chicken

Posted on • Originally published at preciouschicken.com on

Look Ma, no Neovim plugin manager!

Handsfree

To manually install a Neovim plugin, for example Tim Pope's Commentary, without using a plug-in manager then at the terminal :

mkdir -p ~/.local/share/nvim/site/pack/tpope/start/commentary
git clone https://tpope.io/vim/commentary.git ~/.local/share/nvim/site/pack/tpope/start/commentary
Enter fullscreen mode Exit fullscreen mode

The install path always follows the pattern of ~/.local/share/nvim/site/pack/foo/start/bar, where the variables foo and bar can be whatever makes sense to you. Commonly foo is the name of the author (e.g. tpope) and bar is the name of the plugin (e.g. commentary).

Automation

Which is great, but from time to time your plugins will get updated and you will need to pull fresh versions. This can easily be achieved on Linux systems with a small script. Create a file named ~/.local/bin/vimpluginupdate and paste the following:

#!/bin/sh
NVMPTH="$HOME/.local/share/nvim/site/pack"
git -C $NVMPTH/tpope/start/commentary pull || git clone --depth 1 https://tpope.io/vim/commentary.git $NVMPTH/tpope/start/commentary
Enter fullscreen mode Exit fullscreen mode

The rather long git line pulls the repository if it already exists, and if it does not exist (i.e. you haven't done the first step) then it clones a fresh one (using the depth option to just get the latest version and not previous changes).

Now make the file executable:

chmod u+x ~/.local/bin/vimpluginupdate
Enter fullscreen mode Exit fullscreen mode

And whenever you want to update your plugins run1:

vimpluginupdate
Enter fullscreen mode Exit fullscreen mode

As you install more updates simply add new lines.

Helptags

To load any help documentation associated with the plugin then run :helptags ALL within Neovim when the plugin is active. So for instance the vim-commentary plugin will be active when Neovim has open any file recognised as a programming language (i.e. any file with an extension .js, .py, etc). In vim-commentary's case the help docs can then be accessed with :help commentary.

But I use vim?

All I've really done here is amended the vim-commentary install section, so check that out for standard vim (NB - the main difference is the directory used).

I demand an authoritative source

See :help packages and :help add-package.

Version control

This was tested corrected on Ubuntu Linux 22.04 LTS and Neovim v0.6.1.


  1. Interestingly the ~/.local/bin/ directory is not added to your PATH on a fresh install, so if the command does not work at first, log out then in again. 

Discussion (0)