From 179dcb9aa978985dde9a5973500315aed9d92711 Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Fri, 13 Sep 2024 12:47:49 +0100 Subject: [PATCH] feat: add installation script for neovim Added a simple script to install neovim from the GitHub Releases page as a replacement for building it from scratch. --- scripts/install-neovim | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 scripts/install-neovim diff --git a/scripts/install-neovim b/scripts/install-neovim new file mode 100755 index 0000000..62889fa --- /dev/null +++ b/scripts/install-neovim @@ -0,0 +1,48 @@ +#!/usr/bi/env bash + +set -o errexit +set -o nounset +set -o pipefail + +if [ -z ${1+x} ]; then + echo "ERROR: Please specify the version of neovim that you want to install" + exit 1 +fi + +VERSION="$( echo ${1} | sed 's/v//g')" + +echo "Installing neovim version ${VERSION}" + +INSTALLATION_DIR="${HOME}/.local/opt/nvim" +SYMLINK="${HOME}/.local/bin/nvim" +DOWNLOAD_DIR="${HOME}/Downloads/nvim-${VERSION}" + +if [[ -d "${INSTALLATION_DIR}" ]]; then + echo "Moving ${INSTALLATION_DIR} to ${INSTALLATION_DIR}.previous" + mv "${INSTALLATION_DIR}" "${INSTALLATION_DIR}.previous" +fi + +echo "Creating ${INSTALLATION_DIR}" +mkdir "${INSTALLATION_DIR}" + +echo "Downloading neovim to ${DOWNLOAD_DIR}" +mkdir "${DOWNLOAD_DIR}" +curl -s \ + -L "https://github.com/neovim/neovim/releases/download/v${VERSION}/nvim-linux64.tar.gz" \ + -o "${DOWNLOAD_DIR}/nvim-linux64.tar.gz" + +curl -s \ + -L "https://github.com/neovim/neovim/releases/download/v${VERSION}/nvim-linux64.tar.gz.sha256sum" \ + -o "${DOWNLOAD_DIR}/nvim-linux64.tar.gz.sha256sum" + +echo "Verifying the package" +cd "${DOWNLOAD_DIR}" +sha256sum --check nvim-linux64.tar.gz.sha256sum + +# extract contents to the installation directory +echo "Extracting the package to ${INSTALLATION_DIR}" +tar xzf "${DOWNLOAD_DIR}/nvim-linux64.tar.gz" --strip-components=1 -C ${INSTALLATION_DIR} + +# create the symlink +echo "Creating the symbolic link ${SYMLINK}" +ln -sf ${INSTALLATION_DIR}/bin/nvim ${SYMLINK}