Skip to content

Instantly share code, notes, and snippets.

@darcyparker
Last active July 22, 2024 13:24
Show Gist options
  • Save darcyparker/153124662b05c679c417 to your computer and use it in GitHub Desktop.
Save darcyparker/153124662b05c679c417 to your computer and use it in GitHub Desktop.
Build and install neovim for Debian
#!/usr/bin/env bash
#Build and install neovim for Debian
#See: https://neovim.io/
#See: https://github.com/neovim/neovim/wiki/Building-Neovim#quick-start
#See: https://gist.github.com/darcyparker/153124662b05c679c417
#Save current dir
pushd . > /dev/null || exit
#Install dependencies
sudo apt-get update
sudo apt-get install -y \
autoconf \
automake \
cmake \
g++ \
gettext \
libncurses5-dev \
libtool \
libtool-bin \
libunibilium-dev \
libunibilium4 \
ninja-build \
pkg-config \
python3-pip \
software-properties-common \
unzip
# Enable use of python plugins
# Note: python neovim module was renamed to pynvim
# https://github.com/neovim/neovim/wiki/Following-HEAD#steps-to-update-pynvim-formerly-neovim-python-package
# pip3 uninstall pynvim neovim
pip3 install setuptools
pip3 install --upgrade pynvim
gem install neovim
npm install -g neovim
#Get or update neovim github repo
mkdir -p ~/src
cd ~/src || exit
if [ ! -e ~/src/neovim ]; then
git clone https://github.com/neovim/neovim
else
cd neovim || exit
git pull origin
fi
cd ~/src/neovim || exit
git checkout master
#Remove old build dir and .deps dir
rm -rf build/
rm -rf .deps/
make distclean
# Build and install neovim
make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=/usr/local/"
make install
# Enable use of ruby plugins
# sudo gem install neovim
#Restore dir
popd > /dev/null || exit
echo "nvim command: $(command -v nvim)"
echo "nvim command: $(ls -al "$(command -v nvim)")"
@mpwsh
Copy link

mpwsh commented Nov 15, 2019

Tested this on Debian 10 and worked like a charm.
Just a side note:
libunibilium0 is not found on debian repos. Installed libunibilium4 instead and no issues.

Thanks Darcy!

@darcyparker
Copy link
Author

@marianopw - Fixed libunibilium0. The other day I tested and I had libunibilium0 and neovim build worked. The machine I tested on maybe had libunibilium0 from a time when it did exist in repo... then I upgraded. It certainly does not exist now. I updated the script.

@HiggsGaama
Copy link

How to uninstall this? It says It cant make uninstall since there's no such rule for it.

@darcyparker
Copy link
Author

darcyparker commented Oct 5, 2020

@SaffronSlumber - I did not write a script to uninstall. And as you mentioned the nvim dev team did not write a make uninstall rule. This is just a script to help build neovim and run its make install to install it to /usr/local. If you want to remove it, observe the files in stdout that were copied to /user/local/nvim during make install. For example:

/user/local/bin/nvim
/user/local/lib/nvim/
/user/local/share/nvim/
"$HOME/$NVIM_DIR/"

There may be a few other files... Its the usual process for removing a program you'd build from source and install to /usr/local

If you want a clean way to install/remove without building from source, you probably want to use a distribution like https://manjaro.org/

@HiggsGaama
Copy link

@darcyparker Oh, got it. Thanks!!

@marcuslannister
Copy link

In line 65 , it is better change

make install

to

sudo make install

@darcyparker
Copy link
Author

@marcuslannister - I disagree... See comment https://gist.github.com/darcyparker/153124662b05c679c417?permalink_comment_id=3080477#gistcomment-3080477 above. If you want to live dangerously and do sudo make install with MAKE_INSTALL_PREFIX=/usr/local/", go ahead... but I never sudo make install to /usr/local.

@marcuslannister
Copy link

@marcuslannister - I disagree... See comment https://gist.github.com/darcyparker/153124662b05c679c417?permalink_comment_id=3080477#gistcomment-3080477 above. If you want to live dangerously and do sudo make install with MAKE_INSTALL_PREFIX=/usr/local/", go ahead... but I never sudo make install to /usr/local.

Ok, I got it. Thanks.

@osamuaoki
Copy link

As of march 2023, neovim (0.9.0 pre-release) needs ibvterm-dev from experimental (0.3.1-1). Fortunately, this is available in experimental. Also, we use ninja as the build back end. So the above method of making Debian package is not current.

Of course, you can probably build it using upstream source combined with debian/* files in the latest Debian package. But I am making deb package using CMAKE (CPACK). under Debian testing (bookworm).

See https://osamuaoki.github.io/en/2023/03/05/vim-learn-7/#get-latest-neovim

@bestouff
Copy link

Just a big thank you @osamuaoki !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment