Vim 8, released on 12th September, added a new feature of being able to load third party packages natively.
Plugins keep growing and more of them are available than ever before. To keep the collection of plugins manageable package support has been added. This is a convenient way to get one or more plugins, drop them in a directory and possibly keep them updated. Vim will load them automatically, or only when desired. See |packages|
The approach is very similar to the Pathogen package it adds paths to the Vim runtime path where packages can be added. This is sensible as there are very few changes required to switch from Pathogen to using the native functionality.
If you store your
vim configuration in
~/.vim a new folder needs to be created within this folder to hold plugins. This is somewhat confusingly
~/.vim/pack/foo. The folder
foo can be anything. You can keep it at
foo, change it to
my-plugins or your whatever you like. I chose to use my internet handle.
mkdir -p ~/.vim/pack/shapeshed
Within this folder a further folder
start is needed to hold plugins. Vim will pick up any packages added to this folder and automatically load the plugins.
Optionally another folder
opt may be created to hold packages that are not loaded automatically. Packages added in the opt folder may be loaded using
This might be useful for debugging or an ad-hoc plugin.
Directory layout for packages is given as the following.
start/foobar/plugin/foo.vim " always loaded, defines commands start/foobar/plugin/bar.vim " always loaded, defines commands start/foobar/autoload/foo.vim " loaded when foo command used start/foobar/doc/foo.txt " help for foo.vim start/foobar/doc/tags " help tags opt/fooextra/plugin/extra.vim " optional plugin, defines commands opt/fooextra/autoload/extra.vim " loaded when extra command used opt/fooextra/doc/extra.txt " help for extra.vim opt/fooextra/doc/tags " help tags
Other than the opt folder these are the default for existing packages so things are compatible.
The new functionality in vim does not add anything for managing plugins; it just loads them. How you manage plugins is up to you.
Managing packages is directly equivalent to using Pathogen so moving a plugin folder into place, cloning a git repository or using git submodules to move packages into the
start folder are all options. Whilst I am not a huge fan of git submodules my
~/.vim folder is part of my dotfiles and I find that that git submodules work for me.
In the simplest form you can just move a plugin into the
start folder and it will be loaded automatically. It is up to you how you manage it.
Here is an example of how to add a package using Vim’s native approach to packages and git submodules.
cd ~/dotfiles git submodule init git submodule add https://github.com/vim-airline/vim-airline.git vim/pack/shapeshed/start/vim-airline git add .gitmodules vim/pack/shapeshed/start/vim-airline git commit
To update packages is also just a case of updating git submodules.
git submodule update --remote --merge git commit
Removing a package is just a case of removing the git submodule.
git submodule deinit vim/pack/shapeshed/start/vim-airline git rm vim/pack/shapeshed/start/vim-airline rm -Rf .git/modules/vim/pack/shapeshed/start/vim-airline git commit
Vim’s native package management is very closely related to the approach taken by Pathogen in that it adds an additional location to the runtime path that packages can be added to. Beyond that it is up to you to manage the packages themselves, either through zip files, git or mercurial. It adds an additional feature of optional packages that may be loaded on demand.
In my testing I have found that packages work out of the box and I am confident enough to remove Pathogen and use the native approach to loading packages. Pathogen has worked really well for me but less third-party code is a good thing.
Vim’s approach to package management is not particularly user friendly mainly because it pushes the management of packages into user land. Help tags are not automatically generated for packages either (Vundle has this) but this could probably be wrapped up in a script. Git submodules still feel clunky but they have worked well with Pathogen and I am confident this will work for me. Going native and reducing dependencies feels good!
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Listening to BBC Radio with mpv
The BBC publishes high quality 320 kbps HLS AAC streams that can be used to listen to radio from the command-line using mpv. Here are the URLs and some aliases to start listening quickly.
Vim: So long Pathogen, hello native package loading
Vim 8 added a native way to load third-party packages. This means, for me at least, there is no longer any need to use a third party plugin helper like Pathogen.
Linux and Unix more command tutorial with examples
Tutorial on using more, a UNIX and Linux command for viewing the contents of a file or files one screen at a time. Examples of viewing a file, viewing multiple files, searching using regular expressions and opening the file in a text editor.