installer_neovim.sh

Note de lecture générée automatiquement

Le vrai fichier est scripts/linux/installer_neovim.sh (Obsidian n’affiche pas les scripts eux-mêmes). Ne modifie pas cette note : modifie le script, puis relance python3 generer_vues_obsidian.py dans le dossier scripts.

  • À quoi il sert : Neovim 0.12+ (Pop!_OS : archive officielle ; Arch : pacman) + outils
  • Lancer (dans le dossier scripts/linux/) : ./installer_neovim.sh (installe ou met a jour Neovim 0.12+, Pop!_OS ou Arch)
  • Fiche : O12 - Neovim
  • Retour : 00 - Tous les scripts

Code

#!/usr/bin/env bash
# =============================================================================
# installer_neovim.sh — Installe (ou met à jour) la dernière version stable de
#                       Neovim + les outils utilisés par la config de la fiche O12.
#   - Pop!_OS / Debian / Ubuntu : archive officielle GitHub dans /opt,
#     lien /usr/local/bin/nvim, et "vi" / "vim" redirigés vers ce Neovim
#     (la version des dépôts apt est trop ancienne pour vim.pack et le LSP moderne)
#   - Arch : pacman (les dépôts Arch ont déjà la dernière version)
#
# Usage   : ./installer_neovim.sh        (à relancer pour mettre à jour)
# =============================================================================
set -euo pipefail
 
archive="nvim-linux-x86_64.tar.gz"
url="https://github.com/neovim/neovim/releases/latest/download/$archive"
dossier_installation="/opt/nvim-linux-x86_64"
 
if "$(uname -m)" != "x86_64"; then
  echo "Ce script vise un PC x86_64 (ici : $(uname -m))." >&2
  exit 1
fi
 
if command -v pacman >/dev/null 2>&1; then
  echo "== Arch détecté : installation par pacman =="
  sudo pacman -S --needed neovim git curl unzip ripgrep wl-clipboard
 
elif command -v apt-get >/dev/null 2>&1; then
  echo "== Pop!_OS / Debian / Ubuntu détecté =="
  sudo apt-get update
  sudo apt-get install -y git curl unzip tar gzip ripgrep wl-clipboard xclip
 
  dossier_temp="$(mktemp -d)"
  trap 'rm -rf "$dossier_temp"' EXIT
 
  echo "Téléchargement de la dernière version stable de Neovim..."
  curl -fL --progress-bar -o "$dossier_temp/$archive" "$url"
 
  echo "Installation dans $dossier_installation ..."
  sudo rm -rf "$dossier_installation"
  sudo tar -C /opt -xzf "$dossier_temp/$archive"
  # /usr/local/bin passe avant /usr/bin dans le PATH : "nvim" lancera cette version
  sudo ln -sf "$dossier_installation/bin/nvim" /usr/local/bin/nvim
 
  # "vi" et "vim" lancent aussi ce Neovim (sinon ils lancent l'ancienne version apt)
  for nom in vi vim; do
    sudo update-alternatives --install "/usr/bin/$nom" "$nom" /usr/local/bin/nvim 110
    sudo update-alternatives --set "$nom" /usr/local/bin/nvim
  done
 
else
  echo "Distribution non reconnue : installe Neovim à la main (voir la fiche O12)." >&2
  exit 1
fi
 
hash -r
 
echo
echo "== Vérification =="
echo "nvim -> $(command -v nvim)"
nvim --version | head -n 1
if command -v vim >/dev/null 2>&1; then
  echo "vim  -> $(readlink -f "$(command -v vim)")"
fi
if ! command -v npm >/dev/null 2>&1; then
  echo "Attention : npm est absent. Mason en a besoin pour installer pyright et bash-language-server."
fi
echo "Étape suivante : créer ~/.config/nvim/init.lua (fiche O12, partie 6)."