Plugin Management with Dein in NeoVim

Guide to configuring Dein for managing plugins in NeoVim.

In the old days, Emacs featured a complex set of extensions and vi was pretty bare bones by comparison. Those days are gone.

Vim and NeoVim both support a fairly vast selection of plugins and vim plugins are often usable in NeoVim, though the configuration may vary some. And, to some extent they've a better implementation; pulling directly from Git repositories rather than through a central distribution, like Elpa or Marmalade.

This article covers the basics of how to set up NeoVim for extensions and add new extensions.

Configuration

When NeoVim starts, it loads the vimscript located at $HOME/.config/nvim/init.vim. Personally, I prefer to use this file for package configuration, using $HOME/.nvimrc for more general settings, but you can adapt this model to suit your own particular needs.

First, download Dein for vim package management:

user@hostname$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh

Then run the installer:

user@hostname$ sh ./installer.sh ~/.cache/dein

These are the default instructions as defined on GitHub, at the moment. Check for updates if it doesn't work for you.

Add the following lines to your init.vim to set up Dein:

" Dein Package Configuration
if &compatible
  set nocompatible
endif

set runtimepath+='~/.cache/dein/repos/github.com/SHougo/dein.vim'

if dein#load_state('~/.cache/dein')
  call dein#begin('~/.cache/dein')

  call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')

  " Packages
  ...

  " Installation
  if dein#check_install()
     call dein#install()
     let pluginsExists=1
  endif

  call dein#end()
  call dein#save_state()
endif

When you start NeoVim, it loads init.vim, then attempts to load state on the plugins listed in the if block. Any plugin it finds that is not installed, it downloads and installs in the ~/.cache/dein directory.

If you ever want to update your plugins, issue the update command:

:call dein#update()