diff --git a/LazyVim.sh b/LazyVim.sh index df0cbdc..efb2cf5 100755 --- a/LazyVim.sh +++ b/LazyVim.sh @@ -1,51 +1,77 @@ -# Install prerequisetes -if command -v pacman >/dev/null; then +#!/usr/bin/bash + +if ! command -v pacman >/dev/null; then echo "Cannot proceed: Not a arch based system" echo "This script does not have debian support" echo "+ sleep 10" && sleep 10 exit 1 fi + +# Install prerequisetes sudo pacman -S --needed --noconfirm git curl wget python3 python-pip -# Show nvim config replacement +echo "" echo 'This script will move your current nvim config to ~/.config/nvim.bak' echo "Press CTRL+C within 20 secconds if you don't want these actions to be made" sleep 20 +echo "" # Remove old backups -if [ -e "~/.config/nvim.bak" ]; then - # The path exists (it could be a file, a directory, a symlink, etc.) - echo "Path ~/.config/nvim.bak exists. Running command..." - rm -rf ~/.config/nvim.bak +# Remove existing .bak directories first to ensure a clean slate +echo " Checking for and removing old Neovim backup directories..." + +# Use $HOME for reliable path expansion +if [ -e "$HOME/.config/nvim.bak" ]; then + echo "Path $HOME/.config/nvim.bak exists. Removing..." + rm -rf "$HOME/.config/nvim.bak" fi -if [ -e "~/.local/share/nvim.bak" ]; then - # The path exists (it could be a file, a directory, a symlink, etc.) - echo "Path ~/.local/share/nvim.bak exists. Running command..." - rm -rf ~/.local/share/nvim.bak +if [ -e "$HOME/.local/share/nvim.bak" ]; then + echo "Path $HOME/.local/share/nvim.bak exists. Removing..." + rm -rf "$HOME/.local/share/nvim.bak" fi -if [ -e "~/.local/state/nvim.bak" ]; then - # The path exists (it could be a file, a directory, a symlink, etc.) - echo "Path ~/.local/state/nvim.bak exists. Running command..." - rm -rf ~/.local/state/nvim.bak +if [ -e "$HOME/.local/state/nvim.bak" ]; then + echo "Path $HOME/.local/state/nvim.bak exists. Removing..." + rm -rf "$HOME/.local/state/nvim.bak" fi -if [ -e "~/.cache/nvim.bak" ]; then - # The path exists (it could be a file, a directory, a symlink, etc.) - echo "Path ~/.cache/nvim.bak exists. Running command..." - rm -rf ~/.cache/nvim.bak +if [ -e "$HOME/.cache/nvim.bak" ]; then + echo "Path $HOME/.cache/nvim.bak exists. Removing..." + rm -rf "$HOME/.cache/nvim.bak" fi -# LazyVim Backup -mv ~/.config/nvim{,.bak} +# Remove the current nvim config and create a new backup +echo "" +echo " Backing up current Neovim configuration..." +if [ -d "$HOME/.config/nvim" ]; then # Check if nvim config exists before moving + mv "$HOME/.config/nvim" "$HOME/.config/nvim.bak" +else + echo "No existing ~/.config/nvim found to back up." +fi -# optional but recommended -cp ~/.local/share/nvim{,.bak} -r -cp ~/.local/state/nvim{,.bak} -r -cp ~/.cache/nvim{,.bak} -r +echo "" +echo " Backing up Neovim share, state, and cache directories..." +if [ -d "$HOME/.local/share/nvim" ]; then + mv "$HOME/.local/share/nvim" "$HOME/.local/share/nvim.bak" +fi +if [ -d "$HOME/.local/state/nvim" ]; then + mv "$HOME/.local/state/nvim" "$HOME/.local/state/nvim.bak" +fi +if [ -d "$HOME/.cache/nvim" ]; then + mv "$HOME/.cache/nvim" "$HOME/.cache/nvim.bak" +fi -git clone https://github.com/alvinlollo/LazyVim ~/.config/nvim +# Remove any leftover +if [ -e "$HOME/.config/.nvim" ]; then + echo "" + echo "Removing ~/.config/.nvim..." + rm -rf "$HOME/.config/.nvim" +fi + +# Install LazyVim +echo "" +git clone https://github.com/alvinlollo/LazyVim "$HOME/.config/nvim" # Dependencys for Gdoc.vim #wget https://raw.githubusercontent.com/alvinlollo/Single-install-script/refs/heads/main/requirements.txt