torresjrjr(7) 0x85A5ADE2

How to install a Vim plugin from a git repository

· Byron Torres

Have the plugin’s git repository clone link URL prepared. For example:

https://git.sr.ht/~torresjrjr/march.vim

Method 1 – Use a Vim plugin manager

I recommend junegunn/vim-plug. Follow vim-plug’s installation and usage instructions. You should then have a line in your vimrc file like this, for example:

:Plug 'https://git.sr.ht/~torresjrjr/march.vim'

Make sure to follow the plugin’s extra instructions, if any.

Method 2 – Install manually using git and Vim 8 ‘packages’

Vim version 8 and later has a great feature called ‘packages’. To install a plugin, you need to download it to a particular place in your ~/.vim directory, or wherever your configuration lives. Clone the repository to an appropriate directory by running this shell command, substitute the correct clone URL, the correct ~/.vim folder, and the correct plugin name at the end:

git clone https://example.org/.../REPOSITORY \
	VIM_DIRECTORY/pack/plugins/start/REPOSITORY

For example:

git clone https://git.sr.ht/~torresjrjr/march.vim \
	~/.vim/pack/plugins/start/march.vim

Make sure to follow the plugin’s extra instructions, if any.

Once you open vim again, the plugin should be loaded automatically.

Updating your plugin

To update this plugin, go to the plugin’s directory (as specified above as the last argument), and use normal git commands to fetch and merge the latest changes.

git log --oneline -10  # show last 10 commits. use this frequently!
git fetch              # get latest changes
git merge              # sync your local repo to the remote repo
git pull               # fetch and merge in one step

Understanding packages

To understand why this method works, read the following Vim help.

:help packages
:help runtimepath
:help startup
:help load-plugins

Short and sweet. If this was helpful, let me know in the comments.