The easiest way to get neovim on ubuntu or wsl ubuntu, is to simply run sudo apt install neovim
, however, later on you will want to update it, and you will try to uninstall and run sudo apt update
and then install neovim again. All of that to realize that the version remains the same.
I found that the second easiest way of installing and upgrading neovim is to install it form ‘Download’. This will allow you to install the exact version of neovim that you want, and even better, to keep multiple versions of neovim at the same time. Beyond that you can code a script to automatically switch between versions.
This is how I reinstalled neovim without loosing any configuration. I used this article as a reference: https://docs.rockylinux.org/books/nvchad/install_nvim/.
- Backup your config files: I would recommend you to create a Github repository of your neovim configuration files, just in case.
- Check your current nvim bin file: The location might change depending on how you installed neovim. In my case I first installed it using
sudo apt install
. Therefore my nvim folder with all the source code was on/usr/share/
and my bin file or the actual command was on/usr/bin/
. I’m using WSL, so I’m not sure if an actual linux environment will be the same. You can usewhich nvim
to figure out where the bin file is located. - Remove neovim: I removed my current version of neovim with this command:
sudo apt remove neovim -y
. Since this is the most common way of installing in Ubuntu, I’m can’t provide how to uninstall with different package managers. - Download the version of neovim that you want: You will need to get the
nvim-linux64.tar.gz
and thenvim-linux64.tar.gz.sha256sum
files from this link: https://github.com/neovim/neovim/releases. You can download them anywhere you want, if you are using WSL make sure to have them in the linux directory not windows, just to make it easier to find. Try to choose a root folder or create a new folder with only those 2 files, since you’re gonna delete them later on. - Verify the sha256 file: Run this command to verify the file:
sha256sum -c nvim-linux64.tar.gz.sha256sum
.You should get something like this:nvim-linux64.tar.gz: OK
. Remember that both files should be in the same directory. - Unpack the compressed file to the old directory where neovim sourcecode was installed: Going back to step 2, we can use this command (using your own directory):
sudo tar xvzf nvim-linux64.tar.gz -C /usr/share/
. In this step you can actually unpack it anywhere you want, but the directory share is a common one, another similar to this is:~/.local/share
, so feel free to organize it how you like. - Create a symbolic link to the bin file or command: Know we only have to sort of create a shortcut for the executable or command file. Since our configuration is already calling the command
nvim
from the directory in Step 1. We are just going to add a link to the new command. Move to the directory you got in Step 1 and runsudo ln -sf /usr/share/nvim-linux64/bin/nvim nvim
to create the link.
Now open a new terminal or source the config file and run nvim -v
to see the version that you just installed. If you get an error like “nvim command not found”, try going back to Step 1 or installing neovim the old way sudo apt install neovim
to find out where the command was being called from before uninstalling.
Note: Some cache and swap files will be deleted, so you probably won’t be able to see your old neovim commands in the history. Also if you have installed startify, you might get an error, but it should be because you haven’t opened any file yet.
Comments
Post a Comment