From 1ac46d79b9a2354df71f681c1d467f144de5cbfc Mon Sep 17 00:00:00 2001 From: Christian Chiarulli Date: Mon, 30 Aug 2021 01:00:58 -0400 Subject: fix: spacegray -> onedarker --- utils/installer/config.example-no-ts.lua | 2 +- utils/installer/config.example.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/config.example-no-ts.lua b/utils/installer/config.example-no-ts.lua index aad13fe0..f064f306 100644 --- a/utils/installer/config.example-no-ts.lua +++ b/utils/installer/config.example-no-ts.lua @@ -3,7 +3,7 @@ -- general lvim.format_on_save = true lvim.lint_on_save = true -lvim.colorscheme = "spacegray" +lvim.colorscheme = "onedarker" -- keymappings [view all the defaults by pressing Lk] lvim.leader = "space" diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index c2c75fbb..9722f71c 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -12,7 +12,7 @@ an executable lvim.log.level = "warn" lvim.format_on_save = true lvim.lint_on_save = true -lvim.colorscheme = "spacegray" +lvim.colorscheme = "onedarker" -- keymappings [view all the defaults by pressing Lk] lvim.leader = "space" -- cgit v1.2.3 From ca8d855eb0d9182bd1c24248872818701cba79e8 Mon Sep 17 00:00:00 2001 From: Desmond Chan Date: Tue, 31 Aug 2021 02:13:09 +0800 Subject: [Bugfix] Fix cp cannot stat error during installation (#1428) --- utils/installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 9e198274..c39f6c8e 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -214,7 +214,7 @@ function backup_old_config() { rsync --archive -hh --partial --progress --cvs-exclude \ --modify-window=1 "$dir"/ "$dir.bak" else - cp -R "$dir/*" "$dir.bak/." + cp -R "$dir/"* "$dir.bak/." fi done echo "Backup operation complete" -- cgit v1.2.3 From 67a0ee6fddf4c8ce7c5612ce32de684a0683e3ab Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Tue, 31 Aug 2021 12:24:33 +0430 Subject: Fix the installer copy command (#1432) --- utils/installer/install.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index c39f6c8e..ec9813cf 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -210,11 +210,23 @@ function backup_old_config() { # we create an empty folder for subsequent commands \ # that require an existing directory mkdir -p "$dir" "$dir.bak" + touch "$dir/ignore" if command -v rsync &>/dev/null; then rsync --archive -hh --partial --progress --cvs-exclude \ --modify-window=1 "$dir"/ "$dir.bak" else - cp -R "$dir/"* "$dir.bak/." + OS="$(uname -s)" + case "$OS" in + Linux) + cp -r "$dir/"* "$dir.bak/." + ;; + Darwin) + cp -R "$dir/"* "$dir.bak/." + ;; + *) + echo "OS $OS is not currently supported." + ;; + esac fi done echo "Backup operation complete" -- cgit v1.2.3 From 79a4a4295374933617b30ecff8c36bf8f6440d7a Mon Sep 17 00:00:00 2001 From: christianchiarulli Date: Fri, 3 Sep 2021 18:38:18 -0400 Subject: fix: update example config --- utils/installer/config.example.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 9722f71c..5e8d07f8 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -11,7 +11,6 @@ an executable -- general lvim.log.level = "warn" lvim.format_on_save = true -lvim.lint_on_save = true lvim.colorscheme = "onedarker" -- keymappings [view all the defaults by pressing Lk] @@ -90,24 +89,22 @@ lvim.builtin.treesitter.highlight.enabled = true -- lvim.lang.python.formatters = { -- { -- exe = "black", --- args = {} -- } -- } -- set an additional linter -- lvim.lang.python.linters = { -- { -- exe = "flake8", --- args = {} -- } -- } -- Additional Plugins -- lvim.plugins = { --- {"folke/tokyonight.nvim"}, { --- "ray-x/lsp_signature.nvim", --- config = function() require"lsp_signature".on_attach() end, --- event = "InsertEnter" --- } +-- {"folke/tokyonight.nvim"}, +-- { +-- "folke/trouble.nvim", +-- cmd = "TroubleToggle", +-- }, -- } -- Autocommands (https://neovim.io/doc/user/autocmd.html) -- cgit v1.2.3 From 91180ce9991b469333adc6b4d44fe491eb727f48 Mon Sep 17 00:00:00 2001 From: premell <65544203+premell@users.noreply.github.com> Date: Sat, 4 Sep 2021 10:33:55 +0200 Subject: Update install.sh (#1465) --- utils/installer/install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index ec9813cf..02fc6800 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -60,15 +60,15 @@ EOF __add_separator "80" - echo "Would you like to check lunarvim's NodeJS dependencies?" + echo "Would you like to install 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?" + echo "Would you like to install 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?" + echo "Would you like to install lunarvim's Rust dependencies?" read -p "[y]es or [n]o (default: no) : " -r answer [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps -- cgit v1.2.3 From 45c7987768b56be5b836f4a66459a13a51c29489 Mon Sep 17 00:00:00 2001 From: Landon Schropp Date: Sat, 4 Sep 2021 17:47:15 -0500 Subject: Fix a small typo in config.example.lua (#1473) --- utils/installer/config.example.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 5e8d07f8..21a5beac 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -41,10 +41,10 @@ lvim.keys.normal_mode[""] = ":w" -- name = "+Trouble", -- r = { "Trouble lsp_references", "References" }, -- f = { "Trouble lsp_definitions", "Definitions" }, --- d = { "Trouble lsp_document_diagnostics", "Diagnosticss" }, +-- d = { "Trouble lsp_document_diagnostics", "Diagnostics" }, -- q = { "Trouble quickfix", "QuickFix" }, -- l = { "Trouble loclist", "LocationList" }, --- w = { "Trouble lsp_workspace_diagnostics", "Diagnosticss" }, +-- w = { "Trouble lsp_workspace_diagnostics", "Diagnostics" }, -- } -- TODO: User Config for predefined plugins -- cgit v1.2.3 From 064187549478ab94057a0841b2678ada6e993089 Mon Sep 17 00:00:00 2001 From: rebuilt Date: Wed, 8 Sep 2021 14:09:22 +0200 Subject: Correct path of uninstall script. (#1500) --- utils/installer/uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/installer') diff --git a/utils/installer/uninstall.sh b/utils/installer/uninstall.sh index 8d9d039a..09923bb1 100755 --- a/utils/installer/uninstall.sh +++ b/utils/installer/uninstall.sh @@ -1,5 +1,5 @@ #!/bin/sh -USER_BIN_DIR="/usr/local/bin" +USER_BIN_DIR="$HOME/.local/bin" if [ -d "/data/data/com.termux" ]; then sudo() { eval "$@" -- cgit v1.2.3 From fcb764cd638ddffbe96228c6b3b1b8e0d40dbb23 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Mon, 13 Sep 2021 11:10:07 +0200 Subject: refactor(ci): better path handling (#1531) --- utils/installer/install-neovim-from-release | 2 +- utils/installer/install.sh | 30 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/install-neovim-from-release b/utils/installer/install-neovim-from-release index a2ba0513..e20a4804 100755 --- a/utils/installer/install-neovim-from-release +++ b/utils/installer/install-neovim-from-release @@ -52,7 +52,7 @@ function download_neovim() { function verify_neovim() { echo "Verifying the installation.." - DOWNLOADED_SHA="$(sha256sum "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" | awk '{print $1}')" + DOWNLOADED_SHA="$(openssl dgst -sha256 "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz" | awk '{print $2}')" if [ "$RELEASE_SHA" != "$DOWNLOADED_SHA" ]; then echo "Error! checksum mis-match." diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 02fc6800..876e3cd0 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -2,7 +2,7 @@ set -eo pipefail #Set branch to master unless specified by the user -declare -r LV_BRANCH="${LV_BRANCH:-rolling}" +declare LV_BRANCH="${LV_BRANCH:-"rolling"}" declare -r LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}" declare -r INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}" @@ -10,16 +10,16 @@ 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"}" -# TODO: Use a dedicated cache directory #1256 -declare -r NEOVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim" - declare -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" +# TODO: Use a dedicated cache directory #1256 +declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim" +declare -r LUNARVIM_PACK_DIR="$LUNARVIM_RUNTIME_DIR/site/pack" declare -a __lvim_dirs=( "$LUNARVIM_CONFIG_DIR" "$LUNARVIM_RUNTIME_DIR" - "$NEOVIM_CACHE_DIR" # for now this is shared with neovim + "$LUNARVIM_CACHE_DIR" ) declare -a __npm_deps=( @@ -51,6 +51,7 @@ EOF detect_platform if [ -n "$GITHUB_ACTIONS" ]; then + LV_BRANCH="${GITHUB_REF##*/}" install_packer setup_lvim exit 0 @@ -91,11 +92,7 @@ EOF ;; esac - if [ -e "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim" ]; then - echo "Packer already installed" - else - install_packer - fi + install_packer __add_separator "80" @@ -233,8 +230,15 @@ function backup_old_config() { } function install_packer() { - git clone --depth 1 https://github.com/wbthomason/packer.nvim \ - "$LUNARVIM_RUNTIME_DIR/site/pack/packer/start/packer.nvim" + if [ -e "$LUNARVIM_PACK_DIR/packer/start/packer.nvim" ]; then + echo "Packer already installed" + else + if ! git clone --depth 1 "https://github.com/wbthomason/packer.nvim" \ + "$LUNARVIM_PACK_DIR/packer/start/packer.nvim"; then + echo "Failed to clone Packer. Installation failed." + exit 1 + fi + fi } function clone_lvim() { @@ -271,7 +275,7 @@ function setup_lvim() { 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 \ + "$INSTALL_PREFIX/bin/lvim" --headless \ -c 'autocmd User PackerComplete quitall' \ -c 'PackerSync' -- cgit v1.2.3 From e22f9a21c179901e6dfcbdb68d035e70eae4d9e8 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Thu, 16 Sep 2021 09:58:32 +0200 Subject: fix: more robust reloading (#1556) --- utils/installer/install.sh | 2 ++ utils/installer/install_bin.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 utils/installer/install_bin.sh (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 876e3cd0..d2295079 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -294,6 +294,8 @@ function update_lvim() { git -C "$LUNARVIM_RUNTIME_DIR/lvim" merge --ff-only --progress || echo "Unable to guarantee data integrity while updating. Please do that manually instead." && exit 1 fi + echo "Clearing up old startup cache" + "$INSTALL_PREFIX/bin/lvim" --headless +LvimCacheReset +q echo "Your LunarVim installation is now up to date!" } diff --git a/utils/installer/install_bin.sh b/utils/installer/install_bin.sh new file mode 100755 index 00000000..2438d5d1 --- /dev/null +++ b/utils/installer/install_bin.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -eo pipefail + +declare -r 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 -r LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$XDG_DATA_HOME/lunarvim"}" +declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" + +# TODO: Use a dedicated cache directory #1256 +declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim" + +function setup_shim() { + if [ ! -d "$INSTALL_PREFIX/bin" ]; then + mkdir -p "$INSTALL_PREFIX/bin" + fi + cat >"$INSTALL_PREFIX/bin/lvim" < Date: Tue, 21 Sep 2021 01:52:46 -0500 Subject: [Feature]: use yarn to install nodejs dependencies (#1565) * Add yarn support for installer script * Add non-interactive install * Fix installer script bug for cargo --- utils/installer/install.sh | 135 +++++++++++++++++++++++++++++++-------------- 1 file changed, 94 insertions(+), 41 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index d2295079..52d36581 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash + set -eo pipefail #Set branch to master unless specified by the user @@ -31,13 +32,42 @@ declare -a __pip_deps=( "pynvim" ) +function usage() { + echo "Usage: install.sh []" + echo "" + echo "Options:" + echo " -h, --help Print this help message" + echo " -y, --yes Yes for all choices (Install NodeJS, Python, Rust dependencies)" + echo " --overwrite Overwrite previous lvim configuration" +} + +function parse_arguments() { + while [ "$#" -gt 0 ]; do + case "$1" in + -y | --yes) + ARGS_INSTALL_NONINTERACTIVE="y" + ;; + --overwrite) + ARGS_OVERWRITE="y" + ;; + -h | --help) + usage + exit 0 + ;; + esac + shift + done +} + function main() { + parse_arguments "$@" + cat <<'EOF' - 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\ 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 | @@ -61,17 +91,23 @@ EOF __add_separator "80" - echo "Would you like to install lunarvim's NodeJS dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps + if [ -z "$ARGS_INSTALL_NONINTERACTIVE" ]; then + echo "Would you like to install 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 install 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 install 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 install lunarvim's Rust dependencies?" - read -p "[y]es or [n]o (default: no) : " -r answer - [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps + echo "Would you like to install lunarvim's Rust dependencies?" + read -p "[y]es or [n]o (default: no) : " -r answer + [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps + else + install_nodejs_deps + install_python_deps + install_rust_deps + fi __add_separator "80" @@ -80,17 +116,17 @@ EOF __add_separator "80" - case "$@" in - *--overwrite*) - echo "!!Warning!! -> Removing all lunarvim related config \ - because of the --overwrite flag" + if [ -n "$ARGS_OVERWRITE" ]; then + echo "!!Warning!! -> Removing all lunarvim related config \ + because of the --overwrite flag" + if [ -z "$ARGS_INSTALL_NONINTERACTIVE" ]; then 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 + fi + for dir in "${__lvim_dirs[@]}"; do + [ -d "$dir" ] && rm -rf "$dir" + done + fi install_packer @@ -105,7 +141,6 @@ EOF fi __add_separator "80" - } function detect_platform() { @@ -133,14 +168,14 @@ function detect_platform() { } 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" -} - -function check_dep() { - if ! command -v "$1" &>/dev/null; then - print_missing_dep_msg "$1" - exit 1 + if [ "$#" -eq 1 ]; then + echo "[ERROR]: Unable to find dependency [$1]" + echo "Please install it first and re-run the installer. Try: $RECOMMEND_INSTALL $1" + else + local cmds + cmds=$(for i in "$@"; do echo "$RECOMMEND_INSTALL $i"; done) + printf "[ERROR]: Unable to find dependencies [%s]" "$@" + printf "Please install any one of the dependencies and re-run the installer. Try: \n%s\n" "$cmds" fi } @@ -155,8 +190,7 @@ function check_system_deps() { fi } -function install_nodejs_deps() { - check_dep "npm" +function __install_nodejs_deps_npm() { echo "Installing node modules with npm.." for dep in "${__npm_deps[@]}"; do if ! npm ls -g "$dep" &>/dev/null; then @@ -167,6 +201,24 @@ function install_nodejs_deps() { echo "All NodeJS dependencies are succesfully installed" } +function __install_nodejs_deps_yarn() { + echo "Installing node modules with yarn.." + yarn global add "${__npm_deps[@]}" + echo "All NodeJS dependencies are succesfully installed" +} + +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 + eval "__install_nodejs_deps_$pkg_manager" + return + fi + done + print_missing_dep_msg "${pkg_managers[@]}" + exit 1 +} + function install_python_deps() { echo "Verifying that pip is available.." if ! python3 -m ensurepip &>/dev/null; then @@ -183,22 +235,23 @@ function install_python_deps() { } function __attempt_to_install_with_cargo() { - if ! command -v cargo &>/dev/null; then + 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" + echo "[WARN]: Unable to find cargo. Make sure to install it to avoid any problems" + exit 1 fi } # 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 + local -a deps=("fd::fd-find" "rg::ripgrep") + for dep in "${deps[@]}"; do + if ! command -v "${dep%%::*}" &>/dev/null; then + __attempt_to_install_with_cargo "${dep##*::}" + fi + done echo "All Rust dependencies are succesfully installed" } -- cgit v1.2.3 From 938e0f88bc3c27ce019470e0279233a373df61ef Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Tue, 21 Sep 2021 11:56:24 +0200 Subject: fix: remove outdated cache files on install (#1591) --- utils/installer/install.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 52d36581..1bbb05c4 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -318,7 +318,23 @@ EOF chmod +x "$INSTALL_PREFIX/bin/lvim" } +function remove_old_cache_files() { + local packer_cache="$LUNARVIM_CONFIG_DIR/plugin/packer_compiled.lua" + if [ -e "$packer_cache" ]; then + echo "Removing old packer cache file" + rm -f "$packer_cache" + fi + + if [ -e "$LUNARVIM_CACHE_DIR/luacache" ] || [ -e "$LUNARVIM_CACHE_DIR/lvim_cache" ]; then + echo "Removing old startup cache file" + rm -f "$LUNARVIM_CACHE_DIR/{luacache,lvim_cache}" + fi +} + function setup_lvim() { + + remove_old_cache_files + echo "Installing LunarVim shim" setup_shim -- cgit v1.2.3 From 238bbf18ac4e35152be06736c75e94a81e3382e8 Mon Sep 17 00:00:00 2001 From: Abouzar Parvan Date: Sun, 26 Sep 2021 21:11:44 +0330 Subject: fix small bugs in nvim-tree (#1629) --- utils/installer/config.example-no-ts.lua | 2 +- utils/installer/config.example.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/config.example-no-ts.lua b/utils/installer/config.example-no-ts.lua index f064f306..17bb0217 100644 --- a/utils/installer/config.example-no-ts.lua +++ b/utils/installer/config.example-no-ts.lua @@ -43,7 +43,7 @@ lvim.keys.normal_mode[""] = ":w" -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile lvim.builtin.dashboard.active = true lvim.builtin.terminal.active = true -lvim.builtin.nvimtree.side = "left" +lvim.builtin.nvimtree.setup.view.side = "left" lvim.builtin.nvimtree.show_icons.git = 0 -- if you don't want all the parsers change this to a table of the ones you want diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 21a5beac..08a7f3ed 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -51,7 +51,7 @@ lvim.keys.normal_mode[""] = ":w" -- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile lvim.builtin.dashboard.active = true lvim.builtin.terminal.active = true -lvim.builtin.nvimtree.side = "left" +lvim.builtin.nvimtree.setup.view.side = "left" lvim.builtin.nvimtree.show_icons.git = 0 -- if you don't want all the parsers change this to a table of the ones you want -- cgit v1.2.3 From e270bdbd6f9adfd9ae471512c63c3283798481f1 Mon Sep 17 00:00:00 2001 From: Subho Banerjee Date: Thu, 30 Sep 2021 11:53:14 -0500 Subject: [Bugfix]: Use local install in Github actions (#1628) Co-authored-by: kylo252 <59826753+kylo252@users.noreply.github.com> --- utils/installer/install.sh | 69 +++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 26 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 1bbb05c4..d4daf55a 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -17,6 +17,15 @@ declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}" declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim" declare -r LUNARVIM_PACK_DIR="$LUNARVIM_RUNTIME_DIR/site/pack" +declare BASEDIR +BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +BASEDIR="$(dirname -- "$(dirname -- "$BASEDIR")")" +readonly BASEDIR + +declare ARGS_LOCAL=0 +declare ARGS_OVERWRITE=0 +declare ARGS_INSTALL_DEPENDENCIES=1 + declare -a __lvim_dirs=( "$LUNARVIM_CONFIG_DIR" "$LUNARVIM_RUNTIME_DIR" @@ -36,19 +45,26 @@ function usage() { echo "Usage: install.sh []" echo "" echo "Options:" - echo " -h, --help Print this help message" - echo " -y, --yes Yes for all choices (Install NodeJS, Python, Rust dependencies)" - echo " --overwrite Overwrite previous lvim configuration" + echo " -h, --help Print this help message" + echo " -l, --local Install local copy of LunarVim" + echo " --overwrite Overwrite previous LunarVim configuration (a backup is always performed first)" + echo " --[no]-install-dependencies Wheter to prompt to install external dependencies (will prompt by default)" } function parse_arguments() { while [ "$#" -gt 0 ]; do case "$1" in - -y | --yes) - ARGS_INSTALL_NONINTERACTIVE="y" + -l | --local) + ARGS_LOCAL=1 ;; --overwrite) - ARGS_OVERWRITE="y" + ARGS_OVERWRITE=1 + ;; + --install-dependencies) + ARGS_INSTALL_DEPENDENCIES=1 + ;; + --no-install-dependencies) + ARGS_INSTALL_DEPENDENCIES=0 ;; -h | --help) usage @@ -80,18 +96,11 @@ EOF echo "Detecting platform for managing any additional neovim dependencies" detect_platform - if [ -n "$GITHUB_ACTIONS" ]; then - LV_BRANCH="${GITHUB_REF##*/}" - install_packer - setup_lvim - exit 0 - fi - check_system_deps __add_separator "80" - if [ -z "$ARGS_INSTALL_NONINTERACTIVE" ]; then + if [ "$ARGS_INSTALL_DEPENDENCIES" -eq 1 ]; then echo "Would you like to install lunarvim's NodeJS dependencies?" read -p "[y]es or [n]o (default: no) : " -r answer [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps @@ -103,10 +112,6 @@ EOF echo "Would you like to install lunarvim's Rust dependencies?" read -p "[y]es or [n]o (default: no) : " -r answer [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps - else - install_nodejs_deps - install_python_deps - install_rust_deps fi __add_separator "80" @@ -116,13 +121,7 @@ EOF __add_separator "80" - if [ -n "$ARGS_OVERWRITE" ]; then - echo "!!Warning!! -> Removing all lunarvim related config \ - because of the --overwrite flag" - if [ -z "$ARGS_INSTALL_NONINTERACTIVE" ]; then - read -p "Would you like to continue? [y]es or [n]o : " -r answer - [ "$answer" == "${answer#[Yy]}" ] && exit 1 - fi + if [ "$ARGS_OVERWRITE" -eq 1 ]; then for dir in "${__lvim_dirs[@]}"; do [ -d "$dir" ] && rm -rf "$dir" done @@ -136,7 +135,11 @@ EOF echo "Updating LunarVim" update_lvim else - clone_lvim + if [ -n "$ARGS_LOCAL" ]; then + link_local_lvim + else + clone_lvim + fi setup_lvim fi @@ -303,6 +306,20 @@ function clone_lvim() { fi } +function link_local_lvim() { + echo "Linking local LunarVim repo" + + # Detect whether it's a symlink or a folder + if [ -d "$LUNARVIM_RUNTIME_DIR/lvim" ]; then + echo "Removing old installation files" + rm -rf "$LUNARVIM_RUNTIME_DIR/lvim" + fi + + mkdir -p "$LUNARVIM_RUNTIME_DIR" + echo " - $BASEDIR -> $LUNARVIM_RUNTIME_DIR/lvim" + ln -s -f "$BASEDIR" "$LUNARVIM_RUNTIME_DIR/lvim" +} + function setup_shim() { if [ ! -d "$INSTALL_PREFIX/bin" ]; then mkdir -p "$INSTALL_PREFIX/bin" -- cgit v1.2.3 From 52dd273ca9bc552c9bacbdbf697818e75ee993d7 Mon Sep 17 00:00:00 2001 From: Jakpat Mingmongkolmitr Date: Fri, 1 Oct 2021 14:04:27 +0700 Subject: fix(installer): fix ARGS_LOCAL condition (#1649) --- utils/installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index d4daf55a..972534bd 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -135,7 +135,7 @@ EOF echo "Updating LunarVim" update_lvim else - if [ -n "$ARGS_LOCAL" ]; then + if [ "$ARGS_LOCAL" -eq 1 ]; then link_local_lvim else clone_lvim -- cgit v1.2.3 From a273c46eee751de4a61360ae0076ed4dac433e5d Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 1 Oct 2021 13:27:06 +0200 Subject: feat: add LvimUpdate command (#1634) * feat: add prelimenary LvimUpdate command * feat: use native process management * feat: add a telescope change-log utility * fix: update readme to include the new command --- utils/installer/install.sh | 89 +++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 52 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 972534bd..82e02358 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash - set -eo pipefail #Set branch to master unless specified by the user @@ -75,52 +74,40 @@ function parse_arguments() { done } +function msg() { + local text="$1" + local div_width="80" + printf "%${div_width}s\n" ' ' | tr ' ' - + printf "%s\n" "$text" +} + function main() { parse_arguments "$@" - cat <<'EOF' + print_logo - 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 | - \__| \______/ \__| \__| \_______|\__| \_/ \__|\__| \__| \__| - -EOF - - __add_separator "80" - - echo "Detecting platform for managing any additional neovim dependencies" + msg "Detecting platform for managing any additional neovim dependencies" detect_platform check_system_deps - __add_separator "80" - if [ "$ARGS_INSTALL_DEPENDENCIES" -eq 1 ]; then - echo "Would you like to install lunarvim's NodeJS dependencies?" + msg "Would you like to install 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 install lunarvim's Python dependencies?" + msg "Would you like to install 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 install lunarvim's Rust dependencies?" + msg "Would you like to install lunarvim's Rust dependencies?" read -p "[y]es or [n]o (default: no) : " -r answer [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps fi - __add_separator "80" - - echo "Backing up old LunarVim configuration" + msg "Backing up old LunarVim configuration" backup_old_config - __add_separator "80" - if [ "$ARGS_OVERWRITE" -eq 1 ]; then for dir in "${__lvim_dirs[@]}"; do [ -d "$dir" ] && rm -rf "$dir" @@ -129,11 +116,8 @@ EOF install_packer - __add_separator "80" - if [ -e "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" ]; then - echo "Updating LunarVim" - update_lvim + bash "$LUNARVIM_RUNTIME_DIR/lvim/utils/installer/update_lvim.sh" else if [ "$ARGS_LOCAL" -eq 1 ]; then link_local_lvim @@ -143,7 +127,9 @@ EOF setup_lvim fi - __add_separator "80" + msg "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]" } function detect_platform() { @@ -287,18 +273,18 @@ function backup_old_config() { function install_packer() { if [ -e "$LUNARVIM_PACK_DIR/packer/start/packer.nvim" ]; then - echo "Packer already installed" + msg "Packer already installed" else if ! git clone --depth 1 "https://github.com/wbthomason/packer.nvim" \ "$LUNARVIM_PACK_DIR/packer/start/packer.nvim"; then - echo "Failed to clone Packer. Installation failed." + msg "Failed to clone Packer. Installation failed." exit 1 fi fi } function clone_lvim() { - echo "Cloning LunarVim configuration" + msg "Cloning LunarVim configuration" if ! git clone --branch "$LV_BRANCH" \ --depth 1 "https://github.com/${LV_REMOTE}" "$LUNARVIM_RUNTIME_DIR/lvim"; then echo "Failed to clone repository. Installation failed." @@ -338,12 +324,12 @@ EOF function remove_old_cache_files() { local packer_cache="$LUNARVIM_CONFIG_DIR/plugin/packer_compiled.lua" if [ -e "$packer_cache" ]; then - echo "Removing old packer cache file" + msg "Removing old packer cache file" rm -f "$packer_cache" fi if [ -e "$LUNARVIM_CACHE_DIR/luacache" ] || [ -e "$LUNARVIM_CACHE_DIR/lvim_cache" ]; then - echo "Removing old startup cache file" + msg "Removing old startup cache file" rm -f "$LUNARVIM_CACHE_DIR/{luacache,lvim_cache}" fi } @@ -352,7 +338,7 @@ function setup_lvim() { remove_old_cache_files - echo "Installing LunarVim shim" + msg "Installing LunarVim shim" setup_shim @@ -368,26 +354,25 @@ function setup_lvim() { 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]" } function update_lvim() { - git -C "$LUNARVIM_RUNTIME_DIR/lvim" fetch --quiet - if ! git -C "$LUNARVIM_RUNTIME_DIR/lvim" diff --quiet "@{upstream}"; then - git -C "$LUNARVIM_RUNTIME_DIR/lvim" merge --ff-only --progress || - echo "Unable to guarantee data integrity while updating. Please do that manually instead." && exit 1 - fi - echo "Clearing up old startup cache" - "$INSTALL_PREFIX/bin/lvim" --headless +LvimCacheReset +q - echo "Your LunarVim installation is now up to date!" + "$INSTALL_PREFIX/bin/lvim" --headless +'LvimUpdate' +q } -function __add_separator() { - local DIV_WIDTH="$1" - printf "%${DIV_WIDTH}s\n" ' ' | tr ' ' - +function print_logo() { + cat <<'EOF' + + 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 | + \__| \______/ \__| \__| \_______|\__| \_/ \__|\__| \__| \__| + +EOF } main "$@" -- cgit v1.2.3 From 8e3cfb77e6b2e02100b937a590dc8d55c0255ecf Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Fri, 1 Oct 2021 16:49:32 +0200 Subject: fix(installer): add missing update call (#1653) --- utils/installer/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index 82e02358..c26fd157 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -117,7 +117,7 @@ function main() { install_packer if [ -e "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" ]; then - bash "$LUNARVIM_RUNTIME_DIR/lvim/utils/installer/update_lvim.sh" + update_lvim else if [ "$ARGS_LOCAL" -eq 1 ]; then link_local_lvim -- cgit v1.2.3 From 0a41e9e11801ebca60230a9a07ca2fa783787852 Mon Sep 17 00:00:00 2001 From: Lee Marlow Date: Sat, 2 Oct 2021 10:02:55 -0600 Subject: docs: spelling fixes and LunarVim name consistency (#1655) --- utils/installer/install.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/install.sh b/utils/installer/install.sh index c26fd157..aaee515d 100755 --- a/utils/installer/install.sh +++ b/utils/installer/install.sh @@ -47,7 +47,7 @@ function usage() { echo " -h, --help Print this help message" echo " -l, --local Install local copy of LunarVim" echo " --overwrite Overwrite previous LunarVim configuration (a backup is always performed first)" - echo " --[no]-install-dependencies Wheter to prompt to install external dependencies (will prompt by default)" + echo " --[no]-install-dependencies Whether to prompt to install external dependencies (will prompt by default)" } function parse_arguments() { @@ -92,15 +92,15 @@ function main() { check_system_deps if [ "$ARGS_INSTALL_DEPENDENCIES" -eq 1 ]; then - msg "Would you like to install lunarvim's NodeJS dependencies?" + msg "Would you like to install LunarVim's NodeJS dependencies?" read -p "[y]es or [n]o (default: no) : " -r answer [ "$answer" != "${answer#[Yy]}" ] && install_nodejs_deps - msg "Would you like to install lunarvim's Python dependencies?" + msg "Would you like to install LunarVim's Python dependencies?" read -p "[y]es or [n]o (default: no) : " -r answer [ "$answer" != "${answer#[Yy]}" ] && install_python_deps - msg "Would you like to install lunarvim's Rust dependencies?" + msg "Would you like to install LunarVim's Rust dependencies?" read -p "[y]es or [n]o (default: no) : " -r answer [ "$answer" != "${answer#[Yy]}" ] && install_rust_deps fi @@ -187,13 +187,13 @@ function __install_nodejs_deps_npm() { npm install -g "$dep" fi done - echo "All NodeJS dependencies are succesfully installed" + echo "All NodeJS dependencies are successfully installed" } function __install_nodejs_deps_yarn() { echo "Installing node modules with yarn.." yarn global add "${__npm_deps[@]}" - echo "All NodeJS dependencies are succesfully installed" + echo "All NodeJS dependencies are successfully installed" } function install_nodejs_deps() { @@ -220,7 +220,7 @@ function install_python_deps() { for dep in "${__pip_deps[@]}"; do python3 -m pip install --user "$dep" done - echo "All Python dependencies are succesfully installed" + echo "All Python dependencies are successfully installed" } function __attempt_to_install_with_cargo() { @@ -241,7 +241,7 @@ function install_rust_deps() { __attempt_to_install_with_cargo "${dep##*::}" fi done - echo "All Rust dependencies are succesfully installed" + echo "All Rust dependencies are successfully installed" } function backup_old_config() { -- cgit v1.2.3 From d01ba08eaec1640ac2d038893525b3ba0af25813 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 3 Oct 2021 16:13:46 +0200 Subject: refactor: auto-generate language configuration (#1584) Refactor the monolithic `lvim.lang` design into a more modular approach. IMPORTANT: run `:LvimUpdate` in order to generate the new ftplugin template files. --- utils/installer/config.example.lua | 15 +- utils/installer/install.ps1 | 280 +++++++++++++++++++++++++++++++++++++ utils/installer/uninstall.ps1 | 1 + 3 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 utils/installer/install.ps1 create mode 100644 utils/installer/uninstall.ps1 (limited to 'utils/installer') diff --git a/utils/installer/config.example.lua b/utils/installer/config.example.lua index 08a7f3ed..346fac98 100644 --- a/utils/installer/config.example.lua +++ b/utils/installer/config.example.lua @@ -55,7 +55,20 @@ lvim.builtin.nvimtree.setup.view.side = "left" lvim.builtin.nvimtree.show_icons.git = 0 -- if you don't want all the parsers change this to a table of the ones you want -lvim.builtin.treesitter.ensure_installed = "maintained" +lvim.builtin.treesitter.ensure_installed = { + "bash", + "c", + "javascript", + "json", + "lua", + "python", + "typescript", + "css", + "rust", + "java", + "yaml", +} + lvim.builtin.treesitter.ignore_install = { "haskell" } lvim.builtin.treesitter.highlight.enabled = true diff --git a/utils/installer/install.ps1 b/utils/installer/install.ps1 new file mode 100644 index 00000000..10adfece --- /dev/null +++ b/utils/installer/install.ps1 @@ -0,0 +1,280 @@ +$ErrorActionPreference = "Stop" # exit when command fails + +# set script variables +# FIXME: temporarily set the branch to the new one +$LV_BRANCH = ($LV_BRANCH, "lang-refactor", 1 -ne $null)[0] +$LV_REMOTE = ($LV_REMOTE, "lunarvim/lunarvim.git", 1 -ne $null)[0] +$INSTALL_PREFIX = ($INSTALL_PREFIX, "$HOME\.local", 1 -ne $null)[0] + +$env:XDG_DATA_HOME = ($env:XDG_DATA_HOME, "$env:APPDATA", 1 -ne $null)[0] +$env:XDG_CONFIG_HOME = ($env:XDG_CONFIG_HOME, "$LOCALAPPDATA", 1 -ne $null)[0] +$env:XDG_CACHE_HOME = ($env:XDG_CACHE_HOME, "$TEMP", 1 -ne $null)[0] +$env:LUNARVIM_RUNTIME_DIR = ($env:LUNARVIM_RUNTIME_DIR, "$env:XDG_DATA_HOME\lunarvim", 1 -ne $null)[0] +$env:LUNARVIM_CONFIG_DIR = ($env:LUNARVIM_CONFIG_DIR, "$env:XDG_CONFIG_HOME\lvim", 1 -ne $null)[0] +$env:LUNARVIM_CACHE_DIR = ($env:LUNARVIM_CACHE_DIR, "$env:XDG_CACHE_HOME\lvim", 1 -ne $null)[0] + + +$__lvim_dirs = ( + "$env:LUNARVIM_CONFIG_DIR", + "$env:LUNARVIM_RUNTIME_DIR", + "$env:LUNARVIM_CACHE_DIR" +) + +function main($cliargs) { + Write-Output " + + 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 | + \__| \______/ \__| \__| \_______|\__| \_/ \__|\__| \__| \__| + + " + + __add_separator "80" + + # skip this in a Github workflow + if ( $null -eq "$GITHUB_ACTIONS" ) { + install_packer + setup_shim + exit + } + + __add_separator "80" + + check_system_deps + + Write-Output "Would you like to check lunarvim's NodeJS dependencies?" + $answer = Read-Host "[y]es or [n]o (default: no) " + if ("$answer" -eq "y" -or "$answer" -eq "Y") { + install_nodejs_deps + } + + Write-Output "Would you like to check lunarvim's Python dependencies?" + $answer = Read-Host "[y]es or [n]o (default: no) " + if ("$answer" -eq "y" -or "$answer" -eq "Y") { + install_python_deps + } + + __add_separator "80" + + Write-Output "Backing up old LunarVim configuration" + backup_old_config + + __add_separator "80" + + if ($cliargs.Contains("--overwrite")) { + Write-Output "!!Warning!! -> Removing all lunarvim related config because of the --overwrite flag" + $answer = Read-Host "Would you like to continue? [y]es or [n]o " + if ("$answer" -ne "y" -and "$answer" -ne "Y") { + exit 1 + } + + foreach ($dir in $__lvim_dirs) { + if (Test-Path "$dir") { + Remove-Item -Force -Recurse "$dir" + } + } + } + + if (Test-Path "$env:LUNARVIM_RUNTIME_DIR\site\pack\packer\start\packer.nvim") { + Write-Output "Packer already installed" + } + else { + install_packer + } + + __add_separator "80" + + if (Test-Path "$env:LUNARVIM_RUNTIME_DIR\lvim\init.lua" ) { + Write-Output "Updating LunarVim" + update_lvim + } + else { + if ($cliargs.Contains("--testing")) { + copy_local_lvim_repository + } + else { + clone_lvim + } + setup_lvim + } + + __add_separator "80" +} + +function print_missing_dep_msg($dep) { + Write-Output "[ERROR]: Unable to find dependency [$dep]" + Write-Output "Please install it first and re-run the installer. Try: $RECOMMEND_INSTALL $dep" +} + +function install_system_package($dep) { + if (Get-Command -Name "winget" -ErrorAction SilentlyContinue) { + Write-Output "[INFO]: Attempting to install dependency [$dep] with winget" + $install_cmd = "winget install --interactive" + } + elseif (Get-Command -Name "scoop" -ErrorAction SilentlyContinue) { + Write-Output "[INFO]: Attempting to install dependency [$dep] with scoop" + # TODO: check if it's fine to not run it with --global + $install_cmd = "scoop install" + } + else { + print_missing_dep_msg "$dep" + exit 1 + } + + try { + Invoke-Command $install_cmd $dep -ErrorAction Stop + } + catch { + print_missing_dep_msg "$dep" + exit 1 + } +} + +function check_system_dep($dep) { + try { + Get-Command -Name $dep -ErrorAction Stop | Out-Null + } + catch { + install_system_package "$dep" + } +} + +function check_system_deps() { + Write-Output "[INFO]: Checking dependencies.." + check_system_dep "git" + check_system_dep "nvim" + +} + +function install_nodejs_deps() { + try { + check_system_dep "node" + Invoke-Command npm install -g neovim tree-sitter-cli -ErrorAction Break + } + catch { + print_missing_dep_msg "$dep" + } +} + +function install_python_deps() { + try { + check_system_dep "pip" + Invoke-Command python -m pip install --user pynvim -ErrorAction Break + } + catch { + print_missing_dep_msg "$dep" + } +} + +function backup_old_config() { + foreach ($dir in $__lvim_dirs) { + # we create an empty folder for subsequent commands \ + # that require an existing directory + if ( Test-Path "$dir") { + New-Item "$dir.bak" -ItemType Directory -Force + Copy-Item -Recurse "$dir\*" "$dir.bak\." + } + } + + Write-Output "Backup operation complete" +} + + +function install_packer() { + Invoke-Command -ErrorAction Stop -ScriptBlock { git clone --progress --depth 1 "https://github.com/wbthomason/packer.nvim" "$env:LUNARVIM_RUNTIME_DIR\site\pack\packer\start\packer.nvim" } +} + +function copy_local_lvim_repository() { + Write-Output "Copy local LunarVim configuration" + Copy-Item -Path "$((Get-Item $PWD).Parent.Parent.FullName)" -Destination "$env:LUNARVIM_RUNTIME_DIR/lvim" -Recurse +} + +function clone_lvim() { + Write-Output "Cloning LunarVim configuration" + try { + Invoke-Command -ErrorAction Stop -ScriptBlock { git clone --progress --branch "$LV_BRANCH" --depth 1 "https://github.com/$LV_REMOTE" "$env:LUNARVIM_RUNTIME_DIR/lvim" } + } + catch { + Write-Output "Failed to clone repository. Installation failed." + exit 1 + } +} + +function setup_shim() { + if ((Test-Path "$INSTALL_PREFIX\bin") -eq $false) { + New-Item "$INSTALL_PREFIX\bin" -ItemType Directory + } + Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\bin\lvim.ps1" -Destination "$INSTALL_PREFIX\bin\lvim.ps1" -Force +} + +function setup_lvim() { + Write-Output "Installing LunarVim shim" + + setup_shim + + Write-Output "Preparing Packer setup" + + if ((Test-Path "$env:LUNARVIM_CONFIG_DIR") -eq $false) { + New-Item "$env:LUNARVIM_CONFIG_DIR" -ItemType Directory + } + + Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\installer\config.example-no-ts.lua" ` + "$env:LUNARVIM_CONFIG_DIR\config.lua" + + Write-Output "Packer setup complete" + + __add_separator "80" + + Copy-Item "$env:LUNARVIM_RUNTIME_DIR\lvim\utils\installer\config.example.lua" "$env:LUNARVIM_CONFIG_DIR\config.lua" + + $answer = Read-Host $(` + "Would you like to create an alias inside your Powershell profile?`n" +` + "(This enables you to start lvim with the command 'lvim') [y]es or [n]o (default: no)" ) + if ("$answer" -eq "y" -and "$answer" -eq "Y") { + create_alias + } + + __add_separator "80" + + Write-Output "Thank you for installing LunarVim!!" + Write-Output "You can start it by running: $INSTALL_PREFIX\bin\lvim.ps1" + Write-Output "Do not forget to use a font with glyphs (icons) support [https://github.com/ryanoasis/nerd-fonts]" +} + + +function update_lvim() { + try { + Invoke-Command git -C "$env:LUNARVIM_RUNTIME_DIR/lvim" status -uno + } + catch { + git -C "$env:LUNARVIM_RUNTIME_DIR/lvim" pull --ff-only --progress -or + Write-Output "Unable to guarantee data integrity while updating. Please do that manually instead." + exit 1 + } + Write-Output "Your LunarVim installation is now up to date!" +} + +function __add_separator($div_width) { + "-" * $div_width + Write-Output "" +} + +function create_alias { + if($null -eq $(Get-Alias | Select-String "lvim")){ + Add-Content -Path $PROFILE -Value $(-join @('Set-Alias lvim "', "$INSTALL_PREFIX", '\bin\lvim.ps1"')) + + Write-Output "" + Write-Host 'To use the new alias in this window reload your profile with ". $PROFILE".' -ForegroundColor Yellow + + }else { + Write-Output "Alias is already set and will not be reset." + } +} + +main "$args" + diff --git a/utils/installer/uninstall.ps1 b/utils/installer/uninstall.ps1 new file mode 100644 index 00000000..b362ff5a --- /dev/null +++ b/utils/installer/uninstall.ps1 @@ -0,0 +1 @@ +Remove-Item -Path "$HOME/.local/share/lunarvim" -Recurse -Force \ No newline at end of file -- cgit v1.2.3 From 8e4f97b0fb499142fa71cf0aa6fbe43cafb81ac8 Mon Sep 17 00:00:00 2001 From: kylo252 <59826753+kylo252@users.noreply.github.com> Date: Sun, 3 Oct 2021 16:23:06 +0200 Subject: fix: restore windows installer default branch --- utils/installer/install.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'utils/installer') diff --git a/utils/installer/install.ps1 b/utils/installer/install.ps1 index 10adfece..9f861125 100644 --- a/utils/installer/install.ps1 +++ b/utils/installer/install.ps1 @@ -1,8 +1,7 @@ $ErrorActionPreference = "Stop" # exit when command fails # set script variables -# FIXME: temporarily set the branch to the new one -$LV_BRANCH = ($LV_BRANCH, "lang-refactor", 1 -ne $null)[0] +$LV_BRANCH = ($LV_BRANCH, "rolling", 1 -ne $null)[0] $LV_REMOTE = ($LV_REMOTE, "lunarvim/lunarvim.git", 1 -ne $null)[0] $INSTALL_PREFIX = ($INSTALL_PREFIX, "$HOME\.local", 1 -ne $null)[0] -- cgit v1.2.3