Setting Up Neovim on WSL2

Let’s keep this short an sweet, assumptions:

Install & Configure NeoVim

Open an Ubunutu terminal

# add the repo
$ sudo add-apt-repository ppa:neovim-ppa/unstable

# update & install
$ sudo apt-get update
$ sudo apt-get install neovim

source

Setup init.vim

run $ nvim, then:

# create a directory to hold the init.vim file
:call mkdir(stdpath('config'), 'p')
# then create an init.vim file
:exe 'edit '.stdpath('config').'/init.vim'

This is sourced from the :h nvim command

Install vim-plug

download and install vim-plug:

$ sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

source

Add some plugins

# edit the init.vim file
$ nvim ~/.config/nvim/init.vim

Sample plugin file

call plug#begin(stdpath('config') . '/plugged')
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
call plug#end()

write the file and run $ nvim again.

:PlugInstall

And you should be all set!

Written on February 24, 2021