diff options
Diffstat (limited to 'utils/installer')
| -rw-r--r-- | utils/installer/config.example.lua | 5 | ||||
| -rwxr-xr-x | utils/installer/install.sh | 38 | ||||
| -rwxr-xr-x | utils/installer/install_bin.sh | 46 | 
3 files changed, 45 insertions, 44 deletions
| diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 03906ada..e3d9fa23 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -55,6 +55,7 @@ lvim.keys.normal_mode["<C-s>"] = ":w<cr>"  -- TODO: User Config for predefined plugins  -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile  lvim.builtin.dashboard.active = true +lvim.builtin.notify.active = true  lvim.builtin.terminal.active = true  lvim.builtin.nvimtree.setup.view.side = "left"  lvim.builtin.nvimtree.show_icons.git = 0 @@ -100,9 +101,7 @@ lvim.builtin.treesitter.highlight.enabled = true  --   buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")  -- end  -- you can overwrite the null_ls setup table (useful for setting the root_dir function) --- lvim.lsp.null_ls.setup = { ---   root_dir = require("lspconfig").util.root_pattern("Makefile", ".git", "node_modules"), --- } +-- lvim.lsp.null_ls.setup.root_dir = require("lspconfig").util.root_pattern("Makefile", ".git", "node_modules")  -- or if you need something more advanced  -- lvim.lsp.null_ls.setup.root_dir = function(fname)  --   if vim.bo.filetype == "javascript" then diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 1dc77513..c30f2efe 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -171,12 +171,11 @@ function print_missing_dep_msg() {  }  function check_neovim_min_version() { -  # TODO: consider locking the requirement to 0.6+ -  local verify_version_cmd='if !has("nvim-0.5.1") | cquit | else | quit | endif' +  local verify_version_cmd='if !has("nvim-0.6.0") | cquit | else | quit | endif'    # exit with an error if min_version not found    if ! nvim --headless -u NONE -c "$verify_version_cmd"; then -    echo "[ERROR]: LunarVim requires at least Neovim v0.5.1 or higher" +    echo "[ERROR]: LunarVim requires at least Neovim v0.6.0 or higher"      exit 1    fi  } @@ -223,19 +222,29 @@ function __install_nodejs_deps_yarn() {  function __validate_node_installation() {    local pkg_manager="$1"    local manager_home -  manager_home="$($pkg_manager config get prefix 2>/dev/null)" + +  if ! command -v "$pkg_manager" &>/dev/null; then +    return 1 +  fi + +  if [ "$pkg_manager" == "npm" ]; then +    manager_home="$(npm config get prefix 2>/dev/null)" +  else +    manager_home="$(yarn global bin 2>/dev/null)" +  fi    if [ ! -d "$manager_home" ] || [ ! -w "$manager_home" ]; then -    echo "[ERROR] Unable to install without administrative privilages. Please set you NPM_HOME correctly and try again." -    exit 1 +    echo "[ERROR] Unable to install using [$pkg_manager] without administrative privileges." +    return 1    fi + +  return 0  }  function install_nodejs_deps() {    local -a pkg_managers=("yarn" "npm")    for pkg_manager in "${pkg_managers[@]}"; do -    if command -v "$pkg_manager" &>/dev/null; then -      __validate_node_installation "$pkg_manager" +    if __validate_node_installation "$pkg_manager"; then        eval "__install_nodejs_deps_$pkg_manager"        return      fi @@ -343,18 +352,7 @@ function link_local_lvim() {  }  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" +  make -C "$LUNARVIM_BASE_DIR" install-bin  }  function remove_old_cache_files() { diff --git a/utils/installer/install_bin.sh b/utils/installer/install_bin.sh index 2438d5d1..4c649b44 100755 --- a/utils/installer/install_bin.sh +++ b/utils/installer/install_bin.sh @@ -1,33 +1,37 @@  #!/usr/bin/env bash  set -eo pipefail -declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" +INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" -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"}" +XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" +XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}" +XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}" -declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" -declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" +LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" +LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" +LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/nvim"}" -# TODO: Use a dedicated cache directory #1256 -declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim" +LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}"  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}" -export LUNARVIM_CACHE_DIR="\${LUNARVIM_CACHE_DIR:-$LUNARVIM_CACHE_DIR}" - -exec nvim -u "\$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "\$@" -EOF -  chmod +x "$INSTALL_PREFIX/bin/lvim" +  local src="$LUNARVIM_BASE_DIR/utils/bin/lvim.template" +  local dst="$INSTALL_PREFIX/bin/lvim" + +  [ ! -d "$INSTALL_PREFIX/bin" ] && mkdir -p "$INSTALL_PREFIX/bin" + +  # remove outdated installation so that `cp` doesn't complain +  rm -f "$dst" + +  cp "$src" "$dst" + +  sed -e s"@RUNTIME_DIR_VAR@\"${LUNARVIM_RUNTIME_DIR}\"@"g \ +    -e s"@CONFIG_DIR_VAR@\"${LUNARVIM_CONFIG_DIR}\"@"g \ +    -e s"@CACHE_DIR_VAR@\"${LUNARVIM_CACHE_DIR}\"@"g "$src" \ +    | tee "$dst" >/dev/null + +  chmod u+x "$dst"  }  setup_shim "$@" +  echo "You can start LunarVim by running: $INSTALL_PREFIX/bin/lvim" | 
