diff options
| -rw-r--r-- | .github/workflows/install.yaml | 17 | ||||
| -rw-r--r-- | README.md | 16 | ||||
| -rw-r--r--[-rwxr-xr-x] | utils/bin/lvim | 5 | ||||
| -rwxr-xr-x | utils/installer/install.sh | 456 | 
4 files changed, 261 insertions, 233 deletions
| diff --git a/.github/workflows/install.yaml b/.github/workflows/install.yaml index 6fb0d49c..f7d9da01 100644 --- a/.github/workflows/install.yaml +++ b/.github/workflows/install.yaml @@ -1,11 +1,11 @@  name: install  on:    push: -    branches: '**' +    branches: "**"    pull_request:      branches: -      - 'master' -      - 'rolling' +      - "master" +      - "rolling"  jobs:    unixish: @@ -38,14 +38,15 @@ jobs:        - name: Install LunarVim          timeout-minutes: 4          run: | -          bash ./utils/installer/install.sh --testing +          mkdir -p "$HOME/.local/share/lunarvim" +          mkdir -p "$HOME/.config/lvim" +          bash ./utils/installer/install.sh        - name: Test LunarVim PackerCompile -        run: if lvim --headless +PackerCompile -c ':qall' 2>&1|grep -q 'Error'; then false; fi +        run: if "$HOME"/.local/bin/lvim --headless +PackerCompile -c ':qall' 2>&1|grep -q 'Error'; then false; fi        - name: Test LunarVim Health -        run: if lvim --headless +checkhealth -c ':qall' 2>&1|grep -q 'Error'; then false; fi - +        run: if "$HOME"/.local/bin/lvim --headless +checkhealth -c ':qall' 2>&1|grep -q 'Error'; then false; fi  #   freebsd:  #     runs-on: macos-latest  #     if: github.event.pull_request.draft == false @@ -53,7 +54,7 @@ jobs:  #     name: "FreeBSD macos-latest"  #     steps:  #       - uses: actions/checkout@v2 -       +  #       - name: Install dependencies for FreeBSD  #         uses: vmactions/[email protected]  #         with: @@ -28,10 +28,20 @@ Make sure you have the newest version of Neovim (0.5).  bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh)  ``` -### Installing -The following command installs LunarVim.  Change `LVBRANCH` to the branch you'd like to install.  `master` for the stable branch and `rolling` for the latest changes. +### Customizing the installation + +The following options are supported by setting environment variables: +- `"$LV_REMOTE"`            Select a different LunarVim remote [default: 'lunarvim/lunarvim.git'] +- `"$LV_BRANCH"`            Select LunarVim's branch [default: 'rolling'] +- `"$INSTALL_PREFIX"`       Select LunarVim's install prefix [default: `'$HOME/.local'`] +- `"$LUNARVIM_RUNTIME_DIR"` Select LunarVim's runtime directory [default: `'$HOME/.local/share/lunarvim'`] +- `"$LUNARVIM_CONFIG_DIR"`  Select LunarVim's configuration directory [default: `'$HOME/.config/lvim'`] + +Putting it all together +  ``` bash -LVBRANCH=rolling bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/rolling/utils/installer/install.sh) +curl -LSs https://raw.githubusercontent.com/lunarvim/lunarvim/rolling/utils/installer/install.sh -O install.sh +INSTALL_PREFIX=/tmp/t1 LUNARVIM_CONFIG_DIR=/tmp/t2 LUNARVIM_RUNTIME_DIR=/tmp/t3 bash ./install.sh  ```  ### BREAKING CHANGE on rolling and master branches diff --git a/utils/bin/lvim b/utils/bin/lvim index c55ddda7..2303be3c 100755..100644 --- a/utils/bin/lvim +++ b/utils/bin/lvim @@ -1,5 +1,6 @@  #!/bin/sh -LUNARVIM_RUNTIME_DIR=${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvim"} +export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.local/share/lunarvim}" +export LUNARVIM_CONFIG_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.config/lvim}" -exec nvim -u "$LUNARVIM_RUNTIME_DIR"/lvim/init.lua "$@" +exec nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@" diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 98040344..989f5595 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -1,272 +1,288 @@ -#!/bin/sh -#Set Variable to master is not set differently -LVBRANCH="${LVBRANCH:-master}" -USER_BIN_DIR="/usr/local/bin" -set -o nounset # error when referencing undefined variable -set -o errexit # exit when command fails - -installnodemac() { -  brew install lua -  brew install node -  brew install yarn -} +#!/usr/bin/env bash +set -eo pipefail -installnodeubuntu() { -  sudo apt install nodejs -  sudo apt install npm -} +#Set branch to master unless specified by the user +declare -r LV_BRANCH="${LV_BRANCH:-rolling}" +declare -r LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" +declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" -installnodetermux() { -  apt install nodejs -} +declare -r XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" +declare -r XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}" +declare -r XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}" -moveoldlvim() { -  echo "Not installing LunarVim" -  echo "Please move your ~/.local/share/lunarvim folder before installing" -  exit -} +# TODO: Use a dedicated cache directory #1256 +declare -r NEOVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim" -installnodearch() { -  sudo pacman -S nodejs -  sudo pacman -S npm -} +declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" +declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" -installnodefedora() { -  sudo dnf install -y nodejs -  sudo dnf install -y npm -} +declare -a __lvim_dirs=( +  "$LUNARVIM_CONFIG_DIR" +  "$LUNARVIM_RUNTIME_DIR" +  "$NEOVIM_CACHE_DIR" # for now this is shared with neovim +) -installnodegentoo() { -  echo "Printing current node status..." -  emerge -pqv net-libs/nodejs -  echo "Make sure the npm USE flag is enabled for net-libs/nodejs" -  echo "If it isn't enabled, would you like to enable it with flaggie? (Y/N)" -  read -r answer -  [ "$answer" != "${answer#[Yy]}" ] && sudo flaggie net-libs/nodejs +npm -  sudo emerge -avnN net-libs/nodejs -} +declare -a __npm_deps=( +  "neovim" +  "tree-sitter-cli" +) -installnode() { -  echo "Installing node..." -  [ "$(uname)" = "Darwin" ] && installnodemac -  grep -q Ubuntu /etc/os-release && installnodeubuntu -  [ -f "/etc/arch-release" ] && installnodearch -  [ -f "/etc/artix-release" ] && installnodearch -  [ -f "/etc/fedora-release" ] && installnodefedora -  [ -f "/etc/gentoo-release" ] && installnodegentoo -  [ -d "/data/data/com.termux" ] && installnodetermux -  [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" -  sudo npm i -g neovim -} +declare -a __pip_deps=( +  "pynvim" +) -installpiponmac() { -  sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py -  python3 get-pip.py -  rm get-pip.py -} +function main() { +  cat <<'EOF' -installpiponubuntu() { -  sudo apt install python3-pip >/dev/null -} +      88\                                                   88\                +      88 |                                                  \__|               +      88 |88\   88\ 888888$\   888888\   888888\ 88\    88\ 88\ 888888\8888\   +      88 |88 |  88 |88  __88\  \____88\ 88  __88\\88\  88  |88 |88  _88  _88\  +      88 |88 |  88 |88 |  88 | 888888$ |88 |  \__|\88\88  / 88 |88 / 88 / 88 | +      88 |88 |  88 |88 |  88 |88  __88 |88 |       \88$  /  88 |88 | 88 | 88 | +      88 |\888888  |88 |  88 |\888888$ |88 |        \$  /   88 |88 | 88 | 88 | +      \__| \______/ \__|  \__| \_______|\__|         \_/    \__|\__| \__| \__| -installpipontermux() { -  apt install python -} +EOF -installpiponarch() { -  sudo pacman -S python-pip -} +  __add_separator "80" -installpiponfedora() { -  sudo dnf install -y pip >/dev/null -} +  echo "Detecting platform for managing any additional neovim dependencies" +  detect_platform -installpipongentoo() { -  sudo emerge -avn dev-python/pip -} +  # skip this in a Github workflow +  if [ -z "$GITHUB_ACTIONS" ]; then +    check_system_deps -installpip() { -  echo "Installing pip..." -  [ "$(uname)" = "Darwin" ] && installpiponmac -  grep -q Ubuntu /etc/os-release && installpiponubuntu -  [ -f "/etc/arch-release" ] && installpiponarch -  [ -f "/etc/fedora-release" ] && installpiponfedora -  [ -f "/etc/gentoo-release" ] && installpipongentoo -  [ -d "/data/data/com.termux" ] && installpipontermux -  [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" -} +    __add_separator "80" + +    echo "Would you like to check lunarvim's NodeJS dependencies?" +    read -p "[y]es or [n]o (default: no) : " -r answer +    [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps + +    echo "Would you like to check lunarvim's Python dependencies?" +    read -p "[y]es or [n]o (default: no) : " -r answer +    [ "$answer" != "${answer#[Yy]}" ] && install_python_deps + +    echo "Would you like to check lunarvim's Rust dependencies?" +    read -p "[y]es or [n]o (default: no) : " -r answer +    [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps -installpynvim() { -  echo "Installing pynvim..." -  if [ -f "/etc/gentoo-release" ]; then -    echo "Installing using Portage" -    sudo emerge -avn dev-python/pynvim +    __add_separator "80" + +    echo "Backing up old LunarVim configuration" +    backup_old_config + +    __add_separator "80" + +  fi + +  case "$@" in +    *--overwrite*) +      echo "!!Warning!! -> Removing all lunarvim related config \ +        because of the --overwrite flag" +      read -p "Would you like to continue? [y]es or [n]o : " -r answer +      [ "$answer" == "${answer#[Yy]}" ] && exit 1 +      for dir in "${__lvim_dirs[@]}"; do +        [ -d "$dir" ] && rm -rf "$dir" +      done +      ;; +  esac + +  if [ -e "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim" ]; then +    echo "Packer already installed"    else -    pip3 install pynvim --user +    install_packer    fi -} -installpacker() { -  git clone https://github.com/wbthomason/packer.nvim ~/.local/share/lunarvim/site/pack/packer/start/packer.nvim -} +  __add_separator "80" -cloneconfig() { -  if [ -d "/data/data/com.termux" ]; then -    sudo() { -      eval "$@" -    } -    USER_BIN_DIR="$HOME/../usr/bin" +  if [ -e "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" ]; then +    echo "Updating LunarVim" +    update_lvim +  else +    clone_lvim +    setup_lvim    fi -  echo "Cloning LunarVim configuration" -  mkdir -p ~/.local/share/lunarvim -  case "$@" in -    *--testing*) -      cp -r "$(pwd)" ~/.local/share/lunarvim/lvim +  __add_separator "80" + +} + +function detect_platform() { +  OS="$(uname -s)" +  case "$OS" in +    Linux) +      if [ -f "/etc/arch-release" ] || [ -f "/etc/artix-release" ]; then +        RECOMMEND_INSTALL="sudo pacman -S" +      elif [ -f "/etc/fedora-release" ] || [ -f "/etc/redhat-release" ]; then +        RECOMMEND_INSTALL="sudo dnf install -y" +      elif [ -f "/etc/gentoo-release" ]; then +        RECOMMEND_INSTALL="emerge install -y" +      else # assume debian based +        RECOMMEND_INSTALL="sudo apt install -y" +      fi +      ;; +    Darwin) +      RECOMMEND_INSTALL="brew install"        ;;      *) -      git clone --branch "$LVBRANCH" https://github.com/lunarvim/lunarvim.git ~/.local/share/lunarvim/lvim +      echo "OS $OS is not currently supported." +      exit 1        ;;    esac -  mkdir -p "$HOME/.config/lvim" -  sudo cp "$HOME/.local/share/lunarvim/lvim/utils/bin/lvim" "$USER_BIN_DIR" -  sudo chmod a+rx "$USER_BIN_DIR"/lvim -  cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example-no-ts.lua" "$HOME/.config/lvim/config.lua" - -  nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ -    +'autocmd User PackerComplete sleep 100m | qall' \ -    +PackerInstall - -  nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" --headless \ -    +'autocmd User PackerComplete sleep 100m | qall' \ -    +PackerSync +} -  printf "\nCompile Complete\n" +function print_missing_dep_msg() { +  echo "[ERROR]: Unable to find dependency [$1]" +  echo "Please install it first and re-run the installer. Try: $RECOMMEND_INSTALL $1" +} -  if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then -    echo 'config.lua already present' -  else -    cp "$HOME/.local/share/lunarvim/lvim/utils/installer/config.example.lua" "$HOME/.config/lvim/config.lua" +function check_dep() { +  if ! command -v "$1" &>/dev/null; then +    print_missing_dep_msg "$1" +    exit 1    fi -  } -asktoinstallnode() { -  echo "node not found" -  printf "Would you like to install node now (y/n)? " -  read -r answer -  [ "$answer" != "${answer#[Yy]}" ] && installnode +function check_system_deps() { +  if ! command -v git &>/dev/null; then +    print_missing_dep_msg "git" +    exit 1 +  fi +  if ! command -v nvim &>/dev/null; then +    print_missing_dep_msg "neovim" +    exit 1 +  fi  } -asktoinstallgit() { -  echo "git not found, please install git" -  exit +function install_nodejs_deps() { +  check_dep "npm" +  echo "Installing node modules with npm.." +  for dep in "${__npm_deps[@]}"; do +    if ! npm ls -g "$dep" &>/dev/null; then +      printf "installing %s .." "$dep" +      npm install -g "$dep" +    fi +  done +  echo "All NodeJS dependencies are succesfully installed"  } -asktoinstallpip() { -  # echo "pip not found" -  # echo -n "Would you like to install pip now (y/n)? " -  # read answer -  # [ "$answer" != "${answer#[Yy]}" ] && installpip -  echo "Please install pip3 before continuing with install" -  exit +function install_python_deps() { +  echo "Verifying that pip is available.." +  if ! python3 -m ensurepip &>/dev/null; then +    print_missing_dep_msg "pip" +    exit 1 +  fi +  echo "Installing with pip.." +  for dep in "${__pip_deps[@]}"; do +    pip3 install --user "$dep" +  done +  echo "All Python dependencies are succesfully installed"  } -installonmac() { -  brew install ripgrep fzf -  npm install -g tree-sitter-cli +function __attempt_to_install_with_cargo() { +  if ! command -v cargo &>/dev/null; then +    echo "Installing missing Rust dependency with cargo" +    cargo install "$1" +  else +    echo "[WARN]: Unable to find fd. Make sure to install it to avoid any problems" +  fi  } -installonubuntu() { -  sudo apt install ripgrep fzf -  sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev -  pip3 install neovim-remote -  npm install -g tree-sitter-cli +# we try to install the missing one with cargo even though it's unlikely to be found +function install_rust_deps() { +  if ! command -v fd &>/dev/null; then +    __attempt_to_install_with_cargo "fd-find" +  fi +  if ! command -v rg &>/dev/null; then +    __attempt_to_install_with_cargo "ripgrep" +  fi +  echo "All Rust dependencies are succesfully installed"  } -installtermux() { -  apt install ripgrep fzf -  pip install neovim-remote -  npm install -g tree-sitter-cli +function backup_old_config() { +  for dir in "${__lvim_dirs[@]}"; do +    # we create an empty folder for subsequent commands \ +    # that require an existing directory +    mkdir -p "$dir" "$dir.bak" +    if command -v rsync &>/dev/null; then +      rsync --archive -hh --partial --info=stats1 --info=progress2 \ +        --modify-window=1 "$dir" "$dir.bak" +    else +      cp -R "$dir/*" "$dir.bak/." +    fi +  done +  echo "Backup operation complete"  } -installonarch() { -  sudo pacman -S ripgrep fzf -  pip3 install neovim-remote -  npm install -g tree-sitter-cli +function install_packer() { +  git clone --progress --depth 1 https://github.com/wbthomason/packer.nvim \ +    "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim"  } -installonfedora() { -  sudo dnf groupinstall "X Software Development" -  sudo dnf install -y fzf ripgrep +function clone_lvim() { +  echo "Cloning LunarVim configuration" +  if ! git clone --progress --branch "$LV_BRANCH" \ +    --depth 1 "https://github.com/${LV_REMOTE}" "$LUNARVIM_RUNTIME_DIR/lvim"; then +    echo "Failed to clone repository. Installation failed." +    exit 1 +  fi  } -installongentoo() { -  sudo emerge -avn sys-apps/ripgrep app-shells/fzf dev-python/neovim-remote virtual/jpeg sys-libs/zlib -  npm install -g tree-sitter-cli +function setup_shim() { +  if [ ! -d "$INSTALL_PREFIX/bin" ]; then +    mkdir -p "$INSTALL_PREFIX/bin" +  fi +  cat >"$INSTALL_PREFIX/bin/lvim" <<EOF +#!/bin/sh + +export LUNARVIM_CONFIG_DIR="\${LUNARVIM_CONFIG_DIR:-$LUNARVIM_CONFIG_DIR}" +export LUNARVIM_RUNTIME_DIR="\${LUNARVIM_RUNTIME_DIR:-$LUNARVIM_RUNTIME_DIR}" + +exec nvim -u "\$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "\$@" +EOF +  chmod +x "$INSTALL_PREFIX/bin/lvim"  } -installextrapackages() { -  [ "$(uname)" = "Darwin" ] && installonmac -  grep -q Ubuntu /etc/os-release && installonubuntu -  [ -f "/etc/arch-release" ] && installonarch -  [ -f "/etc/artix-release" ] && installonarch -  [ -f "/etc/fedora-release" ] && installonfedora -  [ -f "/etc/gentoo-release" ] && installongentoo -  [ -d "/data/data/com.termux" ] && installtermux -  [ "$(uname -s | cut -c 1-10)" = "MINGW64_NT" ] && echo "Windows not currently supported" +function setup_lvim() { +  echo "Installing LunarVim shim" + +  setup_shim + +  echo "Preparing Packer setup" + +  cp "$LUNARVIM_RUNTIME_DIR/lvim/utils/installer/config.example-no-ts.lua" \ +    "$LUNARVIM_CONFIG_DIR/config.lua" + +  nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" --headless \ +    +'autocmd User PackerComplete sleep 100m | qall' \ +    +PackerInstall + +  nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" --headless \ +    +'autocmd User PackerComplete sleep 100m | qall' \ +    +PackerSync + +  echo "Packer setup complete" + +  cp "$LUNARVIM_RUNTIME_DIR/lvim/utils/installer/config.example.lua" "$LUNARVIM_CONFIG_DIR/config.lua" + +  echo "Thank you for installing LunarVim!!" +  echo "You can start it by running: $INSTALL_PREFIX/bin/lvim" +  echo "Do not forget to use a font with glyphs (icons) support [https://github.com/ryanoasis/nerd-fonts]"  } -# Welcome -echo 'Installing LunarVim' - -case "$@" in -  *--overwrite*) -    echo '!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag' -    rm -rf "$HOME/.local/share/lunarvim" -    rm -rf "$HOME/.cache/nvim" -    rm -rf "$HOME/.config/lvim" -    ;; -esac - -# move old lvim directory if it exists -[ -d "$HOME/.local/share/lunarvim" ] && moveoldlvim - -# install node and neovim support -(command -v git >/dev/null && echo "git installed, moving on...") || asktoinstallgit - -# install pip -(command -v pip3 >/dev/null && echo "pip installed, moving on...") || asktoinstallpip - -# install node and neovim support -(command -v node >/dev/null && echo "node installed, moving on...") || asktoinstallnode - -# install pynvim -(pip3 list | grep pynvim >/dev/null && echo "pynvim installed, moving on...") || installpynvim - -if [ -e "$HOME/.local/share/lunarvim/site/pack/packer/start/packer.nvim" ]; then -  echo 'packer already installed' -else -  installpacker -fi - -if [ -e "$HOME/.local/share/lunarvim/lvim/init.lua" ]; then -  echo 'LunarVim already installed' -else -  # clone config down -  cloneconfig "$@" -  # echo 'export PATH=$HOME/.config/nvim/utils/bin:$PATH' >>~/.zshrc -  # echo 'export PATH=$HOME/.config/lunarvim/utils/bin:$PATH' >>~/.bashrc -fi - -if [ "$(uname)" != "Darwin" ]; then -  if [ -e "$HOME/.local/share/applications/lvim.desktop" ]; then -    echo 'Desktop file already available' -  else -    mkdir -p "$HOME/.local/share/applications" -    cp "$HOME/.local/share/lunarvim/lvim/utils/desktop/lvim.desktop" "$HOME/.local/share/applications/lvim.desktop" +function update_lvim() { +  if ! git -C "$LUNARVIM_RUNTIME_DIR/lvim" status -uno &>/dev/null; then +    git -C "$LUNARVIM_RUNTIME_DIR/lvim" pull --ff-only --progress || +      echo "Unable to guarantee data integrity while updating. Please do that manually instead." && exit 1    fi -fi +  echo "Your LunarVim installation is now up to date!" +} + +function __add_separator() { +  local DIV_WIDTH="$1" +  printf "%${DIV_WIDTH}s\n" ' ' | tr ' ' - +} -echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts" -# echo 'export PATH=/home/$USER/.config/lunarvim/utils/bin:$PATH appending to zshrc/bashrc' +main "$@" | 
