Learn Vim at your own pace with my self-study Core Vim Course.

Learn more

Learn Vim at your own pace with my self-study Core Vim Course.

Meet Neovim

#71

Run time:

In this video, we’ll see how to install and set up Neovim so that it reuses your existing Vim configuration files. Most plugins should work in Neovim just like they do in Vim.

Shownotes

The Neovim Wiki has comprehensive instructions on how to install Neovim on various platforms. On OS X, you can install Neovim with homebrew:

brew install neovim

When I recorded this video, the Neovim homebrew formula was available via the Neovim tap. Back then, you had to run brew install neovim/neovim/neovim. Since then, the Neovim formula has been added to Homebrew core, which makes installation slightly simpler.

Reusing Vim configuration

Vim’s runtime files are typically kept in a ~/.vim directory. Neovim uses the XDG base directory specification, which means that your configuration files are kept in a ~/.config/nvim directory. Whereas Vim usually looks for a configuration file at either ~/.vimrc (or ~/.vim/vimrc), Neovim looks for a file at ~/.config/nvim/init.vim.

If you like, you can maintain a different configuration for Vim and Neovim. Alternatively, you can set things up in such a way that both editors use the same configuration files. The second approach allows you to try out Neovim with minimal disruption.

You can find advice on how to reuse your Vim configuration in Neovim by looking up :help nvim-from-vim. First, create a config directory for Neovim:

mkdir -p ~/.config/nvim

Then create a ~/.config/nvim/init.vim file with the following contents:

set runtimepath+=~/.vim,~/.vim/after
set packpath+=~/.vim
source ~/.vimrc

This way, all runtime files and packages in ~/.vim will be loaded by Neovim. Any customisations you make in your ~/.vimrc will now apply to Neovim as well as Vim.

Plugin compatibility

Neovim can run most Vim plugins just fine. As a general rule, if a plugin has been around since before version 8 of Vim came out, then you can be confident that it will work fine in Neovim.

The one area where you have to be cautious is with any plugin that uses job control to perform work asynchronously. Neovim came out with this feature first, way back in 2014. Vim released a similar feature with version 8, but the job control APIs are different. Some plugins offer async functionality whether you run them in Vim 8 or in Neovim, but some plugins may only work in one or the other. This problem doesn’t affect that many plugins since the job control functionality is relatively new, but it is something to watch out for.

Neovim can run any plugin written in Vimscript. But it also supports remote plugins, which can be written in any language. These run in a separate process, using remote procedure calls (RPC) to communicate with the neovim process. Remote plugins are a game changer for plugin authors.

On the wiki, there’s a list of plugins that exploit Neovim’s features, such as remote plugins and the built in terminal. I expect to see this list growing over time.

Case study: Unite and Denite

The Unite plugin by Shougo makes an interesting case study. This is a popular plugin, but it’s always been plagued by poor performance. It’s implemented in Vimscript, which is too slow for the kind of work that Unite does.

The author has given up on trying to fix these performance issues and started a new plugin called Denite. In Denite, all of the heavy-lifting is performed in a separate Python process. Denite does not yet support all of the features of Unite, but it performs much more snappily. If you want to extend the functionality of Denite, you can do so by writing your own plugin in Python. It’s a good showcase for Neovim’s remote plugins.

Further reading

Comments

Level-up your Vim

Training

Boost your productivity with a Vim training class. Join a public class, or book a private session for your team.

Drew hosted a private Vim session for the shopify team that was one of the best workshops I have ever attended.

John Duff, Director of Engineering at Shopify

Publications

Make yourself a faster and more efficient developer with the help of these publications, including Practical Vim (Pragmatic Bookshelf 2012), which has over 50 five-star reviews on Amazon.

After reading it, I've switched to vim as my default editor on a daily basis with no regrets. ★★★★★

Javier Collado

Learn to use Vim efficiently in your Ruby projects

In association with thoughtbot, one of the most well respected Rails consultancies in the world, I've produced a series of screencasts on how to make navigating your Ruby projects with Vim ultra-efficient. Along the way, you’ll also learn how to make Ruby blocks a first-class text object in Vim. This lets you edit Ruby code at a higher level of abstraction. Available to buy from thoughtbot..