After discovering AstroNVim, a great NeoVim configuration that includes all the bells and whistles I needed, I decided to set up NeoVim on my Ubuntu 22.04 system.
However, I found that the default repositories on Ubuntu 22.04 do not provide the latest version of NeoVim, and the unstable repository can be, as its name suggests, unstable.
While solutions like Snap provide an easy installation method, they can be slower due to the virtualization overhead.
To ensure I had the stable I required for AstroVim, I decided to build NeoVim from source. This guide will walk you through the steps to install NeoVim by checking out the Git repository and building the stable version from source.
Prerequisites
Before starting, ensure you have the following prerequisites installed on your system:
- Git
- Build essentials
- CMake
- Ninja
- pkg-config
- libtool
- autoconf
- automake
- cmake
- gettext
- curl
You can install these dependencies with the following commands:
sudo apt update
sudo apt install git build-essential cmake ninja-build pkg-config libtool libtool-bin autoconf automake gettext curl
Cloning the NeoVim Repository
First, clone the NeoVim Git repository to your local machine:
git clone https://github.com/neovim/neovim.git
Navigate to the neovim
directory:
cd neovim
Checking Out the Stable Version
To ensure you're building the stable version, check out the latest stable branch. AstroNVim requires v0.9.5 or newer - the stable branch provided v0.10.0 at the time of writing, so that worked out great.
Checkout the stable tag:
git checkout stable
Building NeoVim
Now, build NeoVim using CMake:
make CMAKE_BUILD_TYPE=RelWithDebInfo
This command will download third-party dependencies, compile the code, and create the necessary binaries. The build process might take a few minutes to complete.
Installing NeoVim
After the build process is complete, install NeoVim using the following command:
cd build && cpack -G DEB && sudo dpkg -i nvim-linux64.deb
This command will generate a DEB package and install it.
No sudo make install
I hear you say? Well, a DEB package - as NeoVim puts it - "should help ensuring the clean removal of installed files". Sounds good.
Verifying the Installation
To verify the installation, you can check the version of NeoVim:
nvim --version
You should see output similar to the following:
NVIM v0.10.0
Build type: RelWithDebInfo
...
And... done!
All right, NeoVim is up and running. Configuring AstroNVim is now just a matter of following a couple of instructions. And that's it! Happy NeoVimming!