summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-09-16 09:58:32 +0200
committerGitHub <[email protected]>2021-09-16 12:28:32 +0430
commite22f9a21c179901e6dfcbdb68d035e70eae4d9e8 (patch)
tree95fc4bbb019089cc62de91d4c722067ea313e10b /utils
parent168eb232d12f86e98f0d90c4e73e0c9968a3cb8e (diff)
fix: more robust reloading (#1556)
Diffstat (limited to 'utils')
-rwxr-xr-xutils/installer/install.sh2
-rwxr-xr-xutils/installer/install_bin.sh33
2 files changed, 35 insertions, 0 deletions
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" <<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"
+}
+
+setup_shim "$@"
+echo "You can start LunarVim by running: $INSTALL_PREFIX/bin/lvim"