From f9fe1124001fe6baf0859bd36dee80f5c1dc9961 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Tue, 4 Jan 2022 21:06:50 +0100 Subject: [PATCH] [AUTOCONFIG][NEOVIM] Add force params --- .env | 4 +++- scripts/tools/neovim/install.sh | 32 ++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.env b/.env index dea5a53..d220353 100644 --- a/.env +++ b/.env @@ -9,4 +9,6 @@ WM=awesome # Install neovim with custom configuration WITH_NEOVIM=yes -WITH_LAZYGIT=yes +# Possible value = yes | no | force +WITH_CUSTOM_NEOVIM_CONFIG=yes +WITH_CUSTOM_LAZYGIT_CONFIG=yes diff --git a/scripts/tools/neovim/install.sh b/scripts/tools/neovim/install.sh index e59b282..e95ccd0 100755 --- a/scripts/tools/neovim/install.sh +++ b/scripts/tools/neovim/install.sh @@ -8,18 +8,30 @@ if [[ "$WITH_NEOVIM" == 'yes' ]]; then echo '[INFO] Neovim already installed' fi - if [[ "$WITH_LAZYGIT" == 'yes' && ! -d "$HOME/.config/lazygit" ]]; then - ln -s "$CWD/configs/lazygit" "$HOME/.config/lazygit" - echo "[INFO] Neovim config linked with symbolic link : $CWD/configs/lazygit -> $HOME/.config/lazygit" + if [[ "$WITH_CUSTOM_LAZYGIT_CONFIG" == 'yes' || "$WITH_CUSTOM_LAZYGIT_CONFIG" == 'force' ]]; then + if [[ -d "$HOME/.config/lazygit" && "$WITH_CUSTOM_LAZYGIT_CONFIG" == 'force' ]]; then + rm -rf "$HOME/.config/lazygit" + echo '[INFO] Lazygit config removed | Forced by environment variable' + fi + if [[ ! -d "$HOME/.config/lazygit" ]]; then + ln -s "$CWD/configs/lazygit" "$HOME/.config/lazygit" + echo "[INFO] Lazygit config linked with symbolic link : $CWD/configs/lazygit -> $HOME/.config/lazygit" + else + echo '[INFO] Lazygit config already linked' + fi fi - - if [[ ! -d "$HOME/.config/nvim" ]]; then - ln -s "$CWD/configs/nvim" "$HOME/.config/nvim" - echo "[INFO] Neovim config linked with symbolic link : $CWD/configs/nvim -> $HOME/.config/nvim" - install_package ripgrep fd dart lazygit rust-analyzer lldb - else - echo '[INFO] Neovim config already linked' + if [[ "$WITH_CUSTOM_NEOVIM_CONFIG" == 'yes' || "$WITH_CUSTOM_NEOVIM_CONFIG" == 'force' ]]; then + if [[ -d "$HOME/.config/nvim" && "$WITH_CUSTOM_NEOVIM_CONFIG" == 'force' ]]; then + rm -rf "$HOME/.config/nvim" + echo '[INFO] Neovim config removed | Forced by environment variable' + fi + if [[ ! -d "$HOME/.config/nvim" ]]; then + ln -s "$CWD/configs/nvim" "$HOME/.config/nvim" + echo "[INFO] Neovim config linked with symbolic link : $CWD/configs/nvim -> $HOME/.config/nvim" + else + echo '[INFO] Neovim config already linked' + fi fi else echo '[INFO] WITH_NEOVIM not equals to yes. Ignoring...'