Skip to main content

La blog

New roads – From Vim to Neovim

While most IDEs or editors offer more or less functionality to emulate Vims basic behavior, it never feels just right. Some features work differently, not at all and good luck with using any of the hundreds of plugins that we all got used to love so much. Neovim however is different. It is a fork of the original, trying to better the development process of the project and going new ways.

This blog post describes my personal journey from Vim to Neovim.

The story begins

I’ve been using Vim for over ten years now and I don’t claim to be an expert. Many built-in features I never use, rare tasks I have to look up and I catch myself sometimes doing repetitive operations. But nevertheless since I’m using this awesome piece of software, I got very familiar with it and any other editor will give me a headache.

I previously tried out Neovim a few years back but the lack of support of some of the plugins I use day in and day out made me step back.

Vim plugins

Here is a non-exhaustive list of functional Vim plugins I use(d) regularly at work and home:

  • NERDTree: Just a little bit nicer than the default netrw explorer.
  • Tagbar: Quick overview and navigation over current file.
  • UltiSnips: Standard snippet engine.
  • YouCompleteMe: Rock solid completion engine.
  • vimtex: Best non-intrusive LaTeX suite.
  • Powerline: Statusline.
  • command-t: Fuzzy access to files or buffers.

One of those plugins, namely Powerline, does not work with Neovim.1 Additionally just like when using the packaged version of Vim on Debian you have to install additional modules to support language bindings. For Python plugins install the Python package pynvim, for Ruby plugins install the gem neovim:

1
2
pip3 install pynvim
gem install neovim

Or on Debian systems install their respectively packaged versions:

1
apt install python3-pynvim ruby-neovim

From the above list those are necessary for the Python plugin YouCompleteMe and the Ruby plugin command-t.

What about Powerline

When moving from Vim to Neovim the only plugin required to replace was Powerline. There exist two prominent statusline plugins with Neovim support:

Since I wanted a transition as smooth as possible from my original Vim configuration and look & feel I opted for vim-airline.

The heavy lifting? – Copy configurations

Now about the actual transition. Fortunately Vim and Neovim use separate configurations. That means you can still fallback to either of them and don’t mess up the original configuration.

Vim configuration:

  • ~/.vimrc
  • ~/.vim/*

Neovim configuration:

  • ~/.config/nvim/init.vim (the “vimrc” main configuration file)
  • ~/.config/nvim/*

Copy your original vimrc to the init.vim. This way no alteration on the original Vim configuration is made, including any plugins.

Secondly copy all custom Vim files (like a plugin manager file) you may have from ~/.vim/ to ~/.config/nvim/.

Dumbbell exercise – Adapt configurations

Replace all occurrences of hardcoded paths in your ìnit.vim, e.g. configuration items like backupdir, undodir, directory, … . That means change the prefix ~/.vim/ to ~/.config/nvim/.

Don’t forget to also configure your plugin directory in your init.vim to use the new path. Following examples show how to configure the two most endorsed plugin managers Vundle and vim-plug.

Vundle

1
2
git clone https://github.com/VundleVim/Vundle.vim.git \
    ~/.config/nvim/bundle/Vundle.vim
1
2
3
4
5
set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" Plugins ...
call vundle#end()

vim-plug

1
2
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
1
2
3
call plug#begin('~/.config/nvim/vim-plug')
" Plug ...
call plug#end()

Cleaning up – Dealing with incompatible plugins

Incompatible plugins have to be removed and a replacement has to be found. For Powerline I selected vim-airline as successor.

Following lines will give a similar look for vim-airline:

1
2
let g:airline_powerline_fonts = 1
let g:airline#extensions#hunks#enabled = 0

For vim-airline to enable specific sections, other plugins might have to be installed, e.g. vim-fugitive for Git support.

Conclusion

While porting my Vim configuration to Neovim, I was able to cleanup unused plugins and refine some plugin choices. Namely I moved from YouCompleteMe to coc, changed my plugin manager from VAM and the Debian manager vim-addon-manager to vim-plug. I replaced command-t with fzf which also had some nice side effects for my shell.

A repository with my Neovim configuration can be found at https://gitlab.com/Lasall/vimfiles.

In a future article I will cover my experience with YouCompleteMe and coc.