Getting started with neovim

neovim

This article is meant to be a short quickstart guide on using neovim on Ubuntu. neovim has been around for a while and we wanted to explore it as a vim alternative. We are on Ubuntu and the plan is to transfer all vim dependencies to neovim.

A quick read revealed most vim plugins, colorschemes etc. work with neovim without any issues. Here’s what we have in plate:

  • plugins: a.vim, ctags, cscope, mini buf explorer, nerd tree, trinity
  • colorscheme: neverland-darkerBefore we proceed, you should know that all of these would work flawlessly after we are done.

start neovim

$ nvim

base directory

No, not $HOME. neovim is much more structured and well planned. So we have everything in:

$XDG_CONFIG_HOME/nvim/init.vim
(default for $XDG_CONFIG_HOME is ~/.config,
assumed in the rest fo the article)

While it’s possible to create a softlink to ~/.vim (you’ll see why) to get things working, we do not have any plan to retain vim.

init file

The default initialization rc file is:

$HOME/.config/nvim/init.vim

So we migrated .vimrc:

$ cp ~/.vimrc ~/.config/nvim/init.vim

Current contents of our ~/.vimrc:

set nu
set ai
set incsearch
set hlsearch
set ts=8
set shiftwidth=8
set ic
set cindent
set cursorline
set splitright
set bg=dark
setlocal spell spelllang=en_gb
set whichwrap+=<,>,h,l,[,]
set shell=/bin/bash
"set mouse=a

autocmd BufWritePre * :%s/\s\+$//e

syntax enable
set hidden
"noremap <F8> <Esc>:syntax on<CR>
"inoremap <F8> <C-o>:syntax on<CR>

set t_Co=256
colorscheme neverland-darker                                                                                      
let Tlist_WinWidth = 10
nmap <F7>  :TrinityToggleTagList<CR>
nmap <F12>  :TrinityToggleNERDTree<CR>

shortcut

This is for those who use the command vi frequently. By default, the softlink vi points to vim on Ubuntu. As we haven’t removed vim yet, we created the alias vi to point at /usr/bin/nvim.

At this point, when we fired neovim, it ownloaded the required spelling files (as we use set spelling rules in the init file). None of the plugins or the colorscheme worked.

vim plugins

We copied all the vim plugins and colorschemes to neovim’s default directory:

$ cp -rv ~/.vim/* ~/.config/nvim/

Everything works now!

mouse enabled by default

However, it seemed mouse click to go to position is enabled by default in neovim. Something we do not want. So we added the following to init.vim:

"disable mouse
set mouse-=a

show line/column number at cursor

To show line and column number at cursor (disabled by default), add:

set ruler

what doesn’t work

If you are fond of vim encryption, you might be disappointed to know that native cryptography is not supported in neovim. While they have some valid reasons, it’s quite handy. There’s the vim.gnupg plugin, but it’s pointless to force text files to have extensions like .pgp., .gpg etc. So yes, we are a bit upset they sealed the road completely, even for the latest blowfish2 available on vim.

final words

You may want to change references to vim in common files like ~/.gitconfig before you uninstall vim related packages.

Leave a Reply

Your email address will not be published. Required fields are marked *