Files

49 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install a current Neovim release under ~/.local (no root needed).
# Linux x86_64/arm64 and macOS. Usage: scripts/install-nvim.sh [version] (default: stable, e.g. v0.11.4)
set -euo pipefail
VERSION="${1:-stable}"
PREFIX="${NVIM_PREFIX:-$HOME/.local}"
case "$(uname -s)-$(uname -m)" in
Linux-x86_64) asset=nvim-linux-x86_64 ;;
Linux-aarch64 | Linux-arm64) asset=nvim-linux-arm64 ;;
Darwin-arm64) asset=nvim-macos-arm64 ;;
Darwin-x86_64) asset=nvim-macos-x86_64 ;;
*)
echo "Unsupported platform: $(uname -s) $(uname -m)" >&2
exit 1
;;
esac
url="https://github.com/neovim/neovim/releases/download/${VERSION}/${asset}.tar.gz"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
echo "Downloading $url"
if command -v curl >/dev/null 2>&1; then
curl -fsSL "$url" -o "$tmp/nvim.tar.gz"
elif command -v wget >/dev/null 2>&1; then
wget -qO "$tmp/nvim.tar.gz" "$url"
else
echo "Need curl or wget." >&2
exit 1
fi
tar -C "$tmp" -xzf "$tmp/nvim.tar.gz"
mkdir -p "$PREFIX/opt" "$PREFIX/bin"
rm -rf "$PREFIX/opt/nvim"
mv "$tmp/$asset" "$PREFIX/opt/nvim"
ln -sf "$PREFIX/opt/nvim/bin/nvim" "$PREFIX/bin/nvim"
if ! "$PREFIX/bin/nvim" --version | head -1; then
echo "nvim won't start here (very old glibc?). Try the AppImage from the release page instead." >&2
exit 1
fi
case ":$PATH:" in
*":$PREFIX/bin:"*) ;;
*) echo "Add $PREFIX/bin to your PATH: export PATH=\"$PREFIX/bin:\$PATH\"" ;;
esac