|
@@ -1,6 +1,8 @@
|
|
|
#!/usr/bin/env bash
|
|
|
set -eo pipefail
|
|
|
|
|
|
+OS="$(uname -s)"
|
|
|
+
|
|
|
#Set branch to master unless specified by the user
|
|
|
declare -x LV_BRANCH="${LV_BRANCH:-"master"}"
|
|
|
declare -xr LV_REMOTE="${LV_REMOTE:-lunarvim/lunarvim.git}"
|
|
@@ -32,6 +34,7 @@ declare -a __lvim_dirs=(
|
|
|
"$LUNARVIM_CONFIG_DIR"
|
|
|
"$LUNARVIM_RUNTIME_DIR"
|
|
|
"$LUNARVIM_CACHE_DIR"
|
|
|
+ "$LUNARVIM_BASE_DIR"
|
|
|
)
|
|
|
|
|
|
declare -a __npm_deps=(
|
|
@@ -135,14 +138,12 @@ function main() {
|
|
|
fi
|
|
|
fi
|
|
|
|
|
|
- backup_old_config
|
|
|
+ remove_old_cache_files
|
|
|
|
|
|
verify_lvim_dirs
|
|
|
|
|
|
if [ "$ARGS_LOCAL" -eq 1 ]; then
|
|
|
link_local_lvim
|
|
|
- elif [ -d "$LUNARVIM_BASE_DIR" ]; then
|
|
|
- validate_lunarvim_files
|
|
|
else
|
|
|
clone_lvim
|
|
|
fi
|
|
@@ -156,7 +157,6 @@ function main() {
|
|
|
}
|
|
|
|
|
|
function detect_platform() {
|
|
|
- OS="$(uname -s)"
|
|
|
case "$OS" in
|
|
|
Linux)
|
|
|
if [ -f "/etc/arch-release" ] || [ -f "/etc/artix-release" ]; then
|
|
@@ -219,15 +219,6 @@ function verify_core_plugins() {
|
|
|
echo "Verification complete!"
|
|
|
}
|
|
|
|
|
|
-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 validate_install_prefix() {
|
|
|
local prefix="$1"
|
|
|
case $PATH in
|
|
@@ -353,43 +344,37 @@ function install_rust_deps() {
|
|
|
echo "All Rust dependencies are successfully installed"
|
|
|
}
|
|
|
|
|
|
-function verify_lvim_dirs() {
|
|
|
- if [ "$ARGS_OVERWRITE" -eq 1 ]; then
|
|
|
- for dir in "${__lvim_dirs[@]}"; do
|
|
|
- [ -d "$dir" ] && rm -rf "$dir"
|
|
|
- done
|
|
|
- fi
|
|
|
-
|
|
|
- for dir in "${__lvim_dirs[@]}"; do
|
|
|
- mkdir -p "$dir"
|
|
|
- done
|
|
|
-}
|
|
|
-
|
|
|
-function backup_old_config() {
|
|
|
- local src="$LUNARVIM_CONFIG_DIR"
|
|
|
+function __backup_dir() {
|
|
|
+ local src="$1"
|
|
|
if [ ! -d "$src" ]; then
|
|
|
return
|
|
|
fi
|
|
|
mkdir -p "$src.old"
|
|
|
- touch "$src/ignore"
|
|
|
msg "Backing up old $src to $src.old"
|
|
|
if command -v rsync &>/dev/null; then
|
|
|
- rsync --archive -hh --stats --partial --copy-links --cvs-exclude "$src"/ "$src.old"
|
|
|
+ rsync --archive --quiet --backup --partial --copy-links --cvs-exclude "$src"/ "$src.old"
|
|
|
else
|
|
|
- OS="$(uname -s)"
|
|
|
case "$OS" in
|
|
|
- Linux | *BSD)
|
|
|
- cp -r "$src/"* "$src.old/."
|
|
|
- ;;
|
|
|
Darwin)
|
|
|
cp -R "$src/"* "$src.old/."
|
|
|
;;
|
|
|
*)
|
|
|
- echo "OS $OS is not currently supported."
|
|
|
+ cp -r "$src/"* "$src.old/."
|
|
|
;;
|
|
|
esac
|
|
|
fi
|
|
|
- msg "Backup operation complete"
|
|
|
+}
|
|
|
+
|
|
|
+function verify_lvim_dirs() {
|
|
|
+ for dir in "${__lvim_dirs[@]}"; do
|
|
|
+ if [ -d "$dir" ]; then
|
|
|
+ if [ "$ARGS_OVERWRITE" -eq 0 ]; then
|
|
|
+ __backup_dir "$dir"
|
|
|
+ fi
|
|
|
+ rm -rf "$dir"
|
|
|
+ fi
|
|
|
+ mkdir -p "$dir"
|
|
|
+ done
|
|
|
}
|
|
|
|
|
|
function clone_lvim() {
|
|
@@ -406,8 +391,8 @@ function link_local_lvim() {
|
|
|
|
|
|
# Detect whether it's a symlink or a folder
|
|
|
if [ -d "$LUNARVIM_BASE_DIR" ]; then
|
|
|
- echo "Removing old installation files"
|
|
|
- rm -rf "$LUNARVIM_BASE_DIR"
|
|
|
+ msg "Moving old files to ${LUNARVIM_BASE_DIR}.old"
|
|
|
+ mv "$LUNARVIM_BASE_DIR" "${LUNARVIM_BASE_DIR}".old
|
|
|
fi
|
|
|
|
|
|
echo " - $BASEDIR -> $LUNARVIM_BASE_DIR"
|
|
@@ -433,8 +418,6 @@ function remove_old_cache_files() {
|
|
|
|
|
|
function setup_lvim() {
|
|
|
|
|
|
- remove_old_cache_files
|
|
|
-
|
|
|
msg "Installing LunarVim shim"
|
|
|
|
|
|
setup_shim
|
|
@@ -456,7 +439,6 @@ function setup_lvim() {
|
|
|
}
|
|
|
|
|
|
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"
|