hpurmann

Fast, non-blocking plugin execution with neovim

Recently, I’ve been working with a bunch of rather big CoffeeScript files. Since I have coffeelint installed, syntastic is checking the current buffer for possible linting errors on every save. This is slow. Really slow. It takes about one second for a 1000 line file.

In that time, vim is blocked. Even worse, when trying to change the buffer while waiting, the UI gets completely messed up by mixing the buffers contents.

Last weekend, I stumbled across Neomake which is implementing asynchronous:make using the new job control API provided by neovim.

That looked promising. Finally I had a good reason to replace vim by neovim. I had been following the progress on neovim for a couple of months.

Switching in most cases just means renaming your vimrc to nvimrc. I took a different approach. Instead of just renaming, I started from an empty config, copying over one by one. I really do recommend that because that way I could get rid of a few commands which are either just default in neovim or which were hacks to make vim work in a sane way.

If you want your cursor to be narrow in insert mode and wide in normal mode, the configuration is a bit different than in vim.

Neomake config

After installing neomake, simply specify which maker you want to use for which file type. For instance, coffeelint is enabled with

let g:neomake_coffeescript_enabled_makers = ['coffeelint']

It makes sense to run a linter on every every buffer save. This auto command will do the job.

autocmd! BufWritePost * Neomake

Comparison

Let’s see how that looks compared to vim. First, vim with syntastic:

And this is neovim with Neomake:

As you can see, the UI is not blocked after performing the save. Instead, the results from coffeelint are being applied asynchronously as soon as they are available.

The future is here

Indeed, the job control implementation is a killer feature of neovim. Thiago’s rejected PR to vim was the reason for creating the fork in the first place. They also implemented a terminal emulator inside of neovim.

But there are lots of other important things in which the neovim collaborators are making great progress. For instance, they introduced continuous integration with code coverage, switched to CMake as the build system and automated the generation of documentation, analysis and nightly builds. The reponse to pull requests is mostly quick and positive.

All of these are signs of a modern software development environment. Additionally, features being worked on sound very promising. For instance, they want to extract away the GUI from the core C codebase. That will allow programs to use neovim under the hood. Imagine your mail program or your browser working with vim key bindings without re-implementing vim behaviour. One project which showcases this is the vim-mode for the Atom editor.

Still not convinced? Then read the very nice neovim write-up by Geoff Greeg, the creator of the silver searcher.

Written by Hendrik Purmann

Software engineer, computer science student and hobby photographer from Berlin