This is a hopefully small post about how I got from my vim setup to a neovim setup.
This does not keep the same config working on vim, and just copies over what I still need. Vim stays functional, they’re running on 2 completely separate configs.
pacman -S neovim
You’ll also want to set your
EDITOR environment variable to
nvim, but I did that at the end
once I knew it actually works.
Initially, I was getting errors complaining about
Error detected while processing /home/jess/dotfiles/vim/.config/vim/vimrc:
E484: Cannot open file /usr/share/nvim/runtime/defaults.vim
E576: Failed to parse ShaDa file: extra bytes in msgpack string at position 3
Press ENTER or type command to continue
I wasn’t expecting neovim to try and load my existing vimrc. I checked the manual and found this in
Ex commands to be executed at startup.
VIMINIT was set to
let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC. I did this
so that I can keep all of vim’s configuration in
$XDG_CONFIG_HOME, and not scattered throughout
my home directory.
An easy fix for this that doesn’t break anything else is to define these only when I’m running vim,
and not anything else. I can do this using a shell alias, and removing the
export’s for the
environment variables, which make them available to all commands.
VIMINIT='let $MYVIMRC="$XDG_CONFIG_HOME/vim/vimrc" | source $MYVIMRC' \
command vim $@
It’s worth noting that this will break vim for anything that calls it indirectly,
since in that case the alias won’t be executed. A true fix for this would be to put that command
ahead of the actual
vim in your
$PATH, making sure to call the real vim in it.
I need to log out and log back in in order to stop VIMINIT being globally set, since my login shell
itself has it set. This probably wouldn’t be an issue if I used a display manager, but I just log
in and type
startx. A workaround would be to export blank settings for these, but I just decided
to log out and log back in.
One re-login later, and executing
nvim starts up cleanly.
My vimrc has a fair amount of stuff in it, some of which isn’t really needed anymore.
and code for bracketed paste (Which, to be honest, I’m not sure if it even does anything on my system. Might as well get rid of it then).
execute pathogen#infect(), as I’ll be using the native package manager (Not neovim
exclusive, introduced in vim 8.0) instead.
I have a custom version of base16-default.vim that removes background colour,
since I’m a weird person who uses transparent terminals. Because of this, I
don’t manage it as a package. Copying it to
fine, and now my neovim starts up without complaints.
Now I can begin to move my packages over to use vim’s package manager.
Vim’s package manager layout seems to be built to be managed by a system package manager, so it’s somewhat more nested than the directory would be if you were using pathogen.
If you want to see the full directory structure, use
:help packages on a
modern (neo)vim, but for my use case, I’ll just make a
directory, as I want all packages to always load. Then it’s the same as
pathogen from there.
I use git submodules to manage my packages (since my dotfiles themselves are in
git), so adding a new package is a matter of going to
git submodule add <repo URL>.
It’s been fun to try to switch to neovim, and seeing how minimal I can get my config (by adding sensible.vim and sleuth.vim to outsource my configuration to someone else, and auto detection respectively. I’ll probably do more tweaking of my config, but for now, this is fine.)
I’m also getting a bug where when I append to the end of a markdown document, the folds aren’t
updating. This happened both with vim-pandoc and
vim-markdown-folding which is what I’m using
now, so I’m assuming it’s a bug with neovim’s recalculation of
zx to recalculate folds works, so I might just bind that to happen whenever I leave insert
mode. Copy pasting a line at the end of the document seems to work.
I don’t care enough to figure out why it’s happening so I’m just going to deal with it until it pisses me off enough.