A Brief Guide on Installing Neovim on WSL 2
There were lots of hurdles I had to hop over when I tried to install Neovim on my WSL 2 environment, so I wrote down a simple guide to look back on. Please note I'm using the Ubuntu distribution, so some of the commands may differ. In any case, let's get started:
- Installed prerequisites:
sudo apt-get install ninja-build gettext cmake unzip curl build-essential
- Navigate to my
~/repos
folder and clone the neovim repository here:cd ~/repos && git clone https://github.com/neovim/neovim
- Ran
cd ~/repos/neovim
and checked out the stable branch withgit checkout stable
- I wanted Neovim installed in a specific directory, namely in my own
~/src
directory. Why? I guess simply to keep things organized. The official neovim repo said installing in the default/usr/local
directory can complicate uninstallation. In any case, we have to build it first by running the following command with some cmake flags:
make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=$HOME/src/neovim" CMAKE_BUILD_TYPE=RelWithDebInfo
(Note you can change the build type here, I went with RelWithDebInfo, best of both worlds.)
- Run the installation with
make install
- Add this line to your .bashrc file:
export PATH="$HOME/src/neovim/bin:$PATH"
and runsource .bashrc
to make the changes permanent.
Check everything is working by running nvim --version
. Your output should look something like:
NVIM v0.10.0
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info
Now to get started with configuring Neovim to your liking, you should first create the config directory with mkdir -p ~/.config/nvim
. From here you can write your own config with the init.lua
starting point lua module, or clone other configs or distributions found on Github. Here's mine if you want to take a look at it.
Another quick note on Lua and Luarocks
Since I'm using lazy.nvim, one of the requirements is to have luarocks installed.