fix install script again

This commit is contained in:
2026-01-16 11:55:47 +00:00
parent cf58fa1f8a
commit 168208cf3d

View File

@@ -17,19 +17,41 @@ need_cmd() { command -v "$1" >/dev/null 2>&1; }
install_neovim_linux() {
# Install latest stable Neovim from GitHub releases (official tarball)
local tmp
local arch tmp url
arch="$(uname -m)"
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' RETURN
local url="https://github.com/neovim/neovim/releases/download/v0.11.5/nvim-linux-x86_64.tar.gz"
case "$arch" in
x86_64|amd64) url="https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz" ;;
aarch64|arm64) url="https://github.com/neovim/neovim/releases/latest/download/nvim-linuxarm64.tar.gz" ;;
*)
echo "Unsupported architecture: $arch" >&2
return 1
;;
esac
# -f: fail on HTTP errors, -L: follow redirects, -S: show errors
curl -fL --retry 3 --retry-delay 1 -o "$tmp/nvim.tar.gz" "$url"
# quick sanity check (avoids "not in gzip format")
if ! tar -tzf "$tmp/nvim.tar.gz" >/dev/null 2>&1; then
echo "Downloaded file is not a valid gzip tarball: $url" >&2
echo "First bytes:" >&2
head -c 200 "$tmp/nvim.tar.gz" | sed -e 's/[^[:print:]\t]/./g' >&2
return 1
fi
sudo rm -rf /opt/nvim
sudo mkdir -p /opt
sudo tar -C /opt -xzf "$tmp/nvim.tar.gz"
sudo mv /opt/nvim-linux64 /opt/nvim
# Ensure /usr/local/bin exists and symlink nvim
# tarball extracts to /opt/nvim-linux64 or /opt/nvim-linuxarm64
local extracted
extracted="$(tar -tzf "$tmp/nvim.tar.gz" | head -n1 | cut -d/ -f1)"
sudo mv "/opt/$extracted" /opt/nvim
sudo mkdir -p /usr/local/bin
sudo ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim
}