Skip to content

Instantly share code, notes, and snippets.

@micaelviana
Last active May 13, 2024 02:34
Show Gist options
  • Save micaelviana/b37ed98e2e42cfea3905e67e412a7aea to your computer and use it in GitHub Desktop.
Save micaelviana/b37ed98e2e42cfea3905e67e412a7aea to your computer and use it in GitHub Desktop.
A script to install my neovim config without sudo
#!/usr/bin/env bash
set -o pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
RESET='\033[0m' # Reset to default color
#check asdf
if command -v asdf &> /dev/null; then
echo "ASDF is installed."
else
echo -e "${GREEN}ASDF is not installed.${RESET}"
echo -e "${GREEN}Installing FZF${RESET}"
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0
cp ~/.bashrc ~/Downloads/.bash_copy
echo ". \"\$HOME/.asdf/asdf.sh\"" >> ~/.bashrc || echo "${YELLOW}It's not possible to install asdf.${RESET}"
echo ". \"\$HOME/.asdf/completions/asdf.bash\"" >> ~/.bashrc || echo "${YELLOW}It's not possible to install asdf.${RESET}"
echo -e "${GREEN}You need to restart your terminal and run the script again.${RESET}"
exit 0
fi
#check neovim
if command -v nvim &> /dev/null; then
echo -e "${RED}Neovim is already installed.${RESET}"
exit 0
fi
#check node version manager
if ! command -v nvm &> /dev/null && ! command -v fnm &> /dev/null ;then
echo Node version manager was not found. Do you want to install?
read -rp "Your choice [y/n]: " choice
case "$choice" in
[Yy])
echo "Ok, lets go"
#download
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
#export variable
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
#install node
nvm install node
;;
[Nn])
echo "Sorry, it's not possible to proceed without a node version manager installed"
;;
*)
echo "Exit"
exit 0
;;
esac
fi
echo -e "${GREEN}Installing neovim${RESET}"
asdf plugin add neovim || exit 0
asdf install neovim stable || exit 0
asdf global neovim stable || exit 0
echo "alias vi=nvim" >> ~/.bashrc || echo "${YELLOW}It's not possible to create the alias.${RESET}"
echo "alias c=clear" >> ~/.bashrc || echo "${YELLOW}It's not possible to create the alias.${RESET}"
echo -e "${GREEN}Installing Neovim dependencies.${RESET}"
echo
dependencies=(
fd
fzf
ripgrep
tree-sitter
zellij
)
for item in "${dependencies[@]}"; do
uppercase_string=$(echo "$item" | tr '[:lower:]' '[:upper:]')
echo -e "${BLUE} $uppercase_string ${RESET}"
asdf plugin add "$item"
asdf install "$item" latest
asdf global "$item" latest || echo "${YELLOW}It's not possible to set $item .${RESET}"
echo
done
echo -e "${BLUE}Node dependencies${RESET}"
npm install -g neovim bash-language-server || echo "${YELLOW}It's not possible to install npm dependencies.${RESET}"
echo
echo -e "${GREEN}Clone dotfiles.${RESET}"
git clone https://github.com/micaelviana/vimfiles ~/.config/nvim
echo -e "${GREEN}Done.${RESET}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment