diff options
Diffstat (limited to 'utils/installer/install.sh')
-rwxr-xr-x | utils/installer/install.sh | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 620d46f5..87f60fd4 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -2,20 +2,20 @@ set -eo pipefail #Set branch to master unless specified by the user -declare LV_BRANCH="${LV_BRANCH:-"master"}" -declare -r LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" -declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" +declare -x LV_BRANCH="${LV_BRANCH:-"master"}" +declare -xr LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" +declare -xr 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"}" +declare -xr XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" +declare -xr XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}" +declare -xr 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"}" -declare -r LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/lvim"}" -declare -r LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}" +declare -xr LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" +declare -xr LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" +declare -xr LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/lvim"}" +declare -xr LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}" -declare -r LUNARVIM_LOG_LEVEL="${LUNARVIM_LOG_LEVEL:-warn}" +declare -xr LUNARVIM_LOG_LEVEL="${LUNARVIM_LOG_LEVEL:-warn}" declare BASEDIR BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" @@ -51,7 +51,7 @@ function usage() { echo " -l, --local Install local copy of LunarVim" echo " -y, --yes Disable confirmation prompts (answer yes to all questions)" echo " --overwrite Overwrite previous LunarVim configuration (a backup is always performed first)" - echo " --[no]-install-dependencies Whether to automatically install external dependencies (will prompt by default)" + echo " --[no-]install-dependencies Whether to automatically install external dependencies (will prompt by default)" } function parse_arguments() { @@ -201,11 +201,11 @@ function print_missing_dep_msg() { } function check_neovim_min_version() { - local verify_version_cmd='if !has("nvim-0.7") | cquit | else | quit | endif' + local verify_version_cmd='if !has("nvim-0.8") | 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.7 or higher" + echo "[ERROR]: LunarVim requires at least Neovim v0.8 or higher" exit 1 fi } @@ -395,7 +395,7 @@ function backup_old_config() { function clone_lvim() { msg "Cloning LunarVim configuration" if ! git clone --branch "$LV_BRANCH" \ - --depth 1 "https://github.com/${LV_REMOTE}" "$LUNARVIM_BASE_DIR"; then + "https://github.com/${LV_REMOTE}" "$LUNARVIM_BASE_DIR"; then echo "Failed to clone repository. Installation failed." exit 1 fi @@ -439,12 +439,14 @@ function setup_lvim() { setup_shim - cp "$LUNARVIM_BASE_DIR/utils/installer/config.example.lua" "$LUNARVIM_CONFIG_DIR/config.lua" + create_desktop_file + + [ ! -f "$LUNARVIM_CONFIG_DIR/config.lua" ] \ + && cp "$LUNARVIM_BASE_DIR/utils/installer/config.example.lua" "$LUNARVIM_CONFIG_DIR/config.lua" echo "Preparing Packer setup" "$INSTALL_PREFIX/bin/lvim" --headless \ - -c "lua require('lvim.core.log'):set_level([[$LUNARVIM_LOG_LEVEL]])" \ -c 'autocmd User PackerComplete quitall' \ -c 'PackerSync' @@ -453,6 +455,21 @@ function setup_lvim() { verify_core_plugins } +function create_desktop_file() { + OS="$(uname -s)" + # TODO: Any other OSes that use desktop files? + ([ "$OS" != "Linux" ] || ! command -v xdg-desktop-menu &>/dev/null) && return + echo "Creating desktop file" + + for d in "$LUNARVIM_BASE_DIR"/utils/desktop/*/; do + size_folder=$(basename "$d") + mkdir -p "$XDG_DATA_HOME/icons/hicolor/$size_folder/apps/" + cp "$LUNARVIM_BASE_DIR/utils/desktop/$size_folder/lvim.svg" "$XDG_DATA_HOME/icons/hicolor/$size_folder/apps" + done + + xdg-desktop-menu install --novendor "$LUNARVIM_BASE_DIR/utils/desktop/lvim.desktop" +} + function print_logo() { cat <<'EOF' |