2021-06-07 05:28:55 +01:00
|
|
|
#!/bin/sh
|
2021-03-19 01:42:44 +00:00
|
|
|
|
2021-07-03 05:13:42 +01:00
|
|
|
# check if git command is installed
|
|
|
|
command -v git > /dev/null || {
|
|
|
|
printf "Install git before proceeding\n"
|
|
|
|
exit 1
|
2021-03-19 01:42:44 +00:00
|
|
|
}
|
|
|
|
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "%s\n" "Installing packer"
|
2021-03-28 18:50:53 +01:00
|
|
|
|
2021-06-27 20:02:56 +01:00
|
|
|
if [ -d ~/.local/share/nvim/site/pack/packer ]; then
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "%s\n" "Clearning previous packer installs"
|
2021-06-27 20:02:56 +01:00
|
|
|
rm -rf ~/.local/share/nvim/site/pack
|
2021-03-28 18:50:53 +01:00
|
|
|
fi
|
|
|
|
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "\n%s\n" "=> Cloning packer.."
|
|
|
|
if git clone https://github.com/wbthomason/packer.nvim \
|
|
|
|
~/.local/share/nvim/site/pack/packer/start/packer.nvim; then
|
|
|
|
printf "%s\n" "=> Packer installed!"
|
|
|
|
else
|
|
|
|
printf "Error: Couldn't clone packer\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-06-27 20:02:56 +01:00
|
|
|
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "%s\n" "Linking config"
|
|
|
|
printf "%s\n" "Old nvim config will be changed to nvim.bak if exists! :0"
|
2021-03-27 02:50:15 +00:00
|
|
|
|
2021-04-08 02:59:39 +01:00
|
|
|
# copying config
|
2021-06-15 10:05:23 +01:00
|
|
|
if [ -d ~/.config/nvim ]; then
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "%s\n" "Nvim Directory exists"
|
|
|
|
printf "%s\n" "Changing nvim to nvim.bak"
|
2021-06-15 10:05:23 +01:00
|
|
|
mv ~/.config/nvim/ ~/.config/nvim.bak/
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "%s\n" "Creating new nvim directory"
|
2021-06-15 10:05:23 +01:00
|
|
|
mkdir -p ~/.config/nvim
|
|
|
|
else
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "%s\n" "Nvim Config doesn't exist so creating one"
|
2021-06-15 10:05:23 +01:00
|
|
|
mkdir -p ~/.config/nvim/
|
|
|
|
fi
|
2021-03-27 02:50:15 +00:00
|
|
|
|
2021-07-03 05:13:42 +01:00
|
|
|
{ cp -r init.lua ~/.config/nvim/ && cp -r lua ~/.config/nvim/ ;} || {
|
|
|
|
printf "Error: Couldn't copy nvim config\n"
|
|
|
|
exit 1
|
|
|
|
}
|
2021-03-27 02:50:15 +00:00
|
|
|
|
2021-06-07 05:28:55 +01:00
|
|
|
# change shell in nvim config
|
2021-07-03 05:13:42 +01:00
|
|
|
_CURRENT_SHELL="${SHELL##*/}"
|
|
|
|
printf "%s\n: " "Which shell do you want to use ? [ Enter nothing for current shell ( $_CURRENT_SHELL ) ]"
|
|
|
|
read -r shellname
|
|
|
|
shellname="${shellname:-${_CURRENT_SHELL}}"
|
|
|
|
printf "%s\n" "$shellname"
|
2021-04-06 05:05:22 +01:00
|
|
|
|
2021-07-03 05:13:42 +01:00
|
|
|
# don't try to do any changes if given shellname is same as bash
|
|
|
|
if ! [ bash = "$shellname" ]; then
|
|
|
|
# Reference: https://stackoverflow.com/a/4247319
|
|
|
|
if "$(command -v sed)" -i'.bak' -e "s/bash/$shellname/g" ~/.config/nvim/lua/mappings.lua; then
|
|
|
|
printf "\n%s\n" "=> Shell changed to $shellname on nvim successfully!"
|
|
|
|
else
|
|
|
|
printf "\n%s\n" "Cannot edit with sed, edit ~/.config/nvim/lua/mappings.lua manually to replace bash with $shellname."
|
|
|
|
fi
|
|
|
|
rm -f ~/.config/nvim/lua/mappings.lua.bak # delete backup file created by sed
|
2021-04-24 13:51:13 +01:00
|
|
|
else
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "\n%s\n" "=> Shell changed to $shellname on nvim successfully!"
|
2021-04-24 13:51:13 +01:00
|
|
|
fi
|
|
|
|
|
2021-07-03 05:13:42 +01:00
|
|
|
printf "\n%s\n" "=> Neovim will open with some errors, just press enter" && sleep 1
|
2021-03-19 01:42:44 +00:00
|
|
|
|
2021-06-26 03:05:33 +01:00
|
|
|
# install all plugins + compile them
|
2021-07-03 05:13:42 +01:00
|
|
|
if _NVIM="$(command -v nvim)"; then
|
|
|
|
"${_NVIM}" +PackerSync
|
|
|
|
else
|
|
|
|
printf "Error: Neovim is not installed, install Neovim >= 5.x and then run the below command\n"
|
|
|
|
printf " nvim +PackerSync\n"
|
|
|
|
exit 1
|
|
|
|
fi
|