summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2021-12-11 19:52:34 +0100
committerGitHub <[email protected]>2021-12-11 19:52:34 +0100
commit872061e179a9e887a0bf8da5d0f2b2f57df1fc66 (patch)
tree1e7fe86a544f6fdfebe03905c3c7693fafec12ca
parent869dc20d117142d6abbe2192ca7e9d956b833614 (diff)
fix(installer): better handling of existing files (#2066)
-rwxr-xr-xutils/installer/install.sh42
1 files changed, 24 insertions, 18 deletions
diff --git a/utils/installer/install.sh b/utils/installer/install.sh
index 722144e3..66205b10 100755
--- a/utils/installer/install.sh
+++ b/utils/installer/install.sh
@@ -12,6 +12,8 @@ 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"}"
+declare -r LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}"
+
# TODO: Use a dedicated cache directory #1256
declare -r LUNARVIM_CACHE_DIR="$XDG_CACHE_HOME/nvim"
@@ -109,17 +111,16 @@ function main() {
verify_lvim_dirs
- if [ -e "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" ]; then
- update_lvim
+ if [ "$ARGS_LOCAL" -eq 1 ]; then
+ link_local_lvim
+ elif [ -e "$LUNARVIM_BASE_DIR/init.lua" ]; then
+ validate_lunarvim_files
else
- if [ "$ARGS_LOCAL" -eq 1 ]; then
- link_local_lvim
- else
- clone_lvim
- fi
- setup_lvim
+ clone_lvim
fi
+ setup_lvim
+
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]"
@@ -181,6 +182,15 @@ function check_neovim_min_version() {
fi
}
+function validate_lunarvim_files() {
+ local verify_version_cmd='if v:errmsg != "" | cquit | else | quit | endif'
+ if ! "$INSTALL_PREFIX/bin/lvim" --headless -c 'LvimUpdate' -c "$verify_version_cmd" &>/dev/null; then
+ msg "Removing old installation files"
+ rm -rf "$LUNARVIM_BASE_DIR"
+ clone_lvim
+ fi
+}
+
function check_system_deps() {
if ! command -v git &>/dev/null; then
print_missing_dep_msg "git"
@@ -301,7 +311,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_RUNTIME_DIR/lvim"; then
+ --depth 1 "https://github.com/${LV_REMOTE}" "$LUNARVIM_BASE_DIR"; then
echo "Failed to clone repository. Installation failed."
exit 1
fi
@@ -311,13 +321,13 @@ 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
+ if [ -d "$LUNARVIM_BASE_DIR" ]; then
echo "Removing old installation files"
- rm -rf "$LUNARVIM_RUNTIME_DIR/lvim"
+ rm -rf "$LUNARVIM_BASE_DIR"
fi
- echo " - $BASEDIR -> $LUNARVIM_RUNTIME_DIR/lvim"
- ln -s -f "$BASEDIR" "$LUNARVIM_RUNTIME_DIR/lvim"
+ echo " - $BASEDIR -> $LUNARVIM_BASE_DIR"
+ ln -s -f "$BASEDIR" "$LUNARVIM_BASE_DIR"
}
function setup_shim() {
@@ -356,7 +366,7 @@ function setup_lvim() {
setup_shim
- cp "$LUNARVIM_RUNTIME_DIR/lvim/utils/installer/config.example.lua" "$LUNARVIM_CONFIG_DIR/config.lua"
+ cp "$LUNARVIM_BASE_DIR/utils/installer/config.example.lua" "$LUNARVIM_CONFIG_DIR/config.lua"
echo "Preparing Packer setup"
@@ -367,10 +377,6 @@ function setup_lvim() {
echo "Packer setup complete"
}
-function update_lvim() {
- "$INSTALL_PREFIX/bin/lvim" --headless +'LvimUpdate' +q
-}
-
function print_logo() {
cat <<'EOF'