Last active
October 4, 2024 22:47
-
-
Save micaelviana/b37ed98e2e42cfea3905e67e412a7aea to your computer and use it in GitHub Desktop.
A script to install my neovim config without sudo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o pipefail | |
GREEN='\033[0;32m' | |
YELLOW='\033[0;33m' | |
BLUE='\033[0;34m' | |
RESET='\033[0m' # Reset to default color | |
#check neovim | |
if command -v nvim &> /dev/null; then | |
echo -e "${RED}Neovim is already installed.${RESET}" | |
exit 0 | |
fi | |
#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 node version manager | |
if ! command -v nvm &> /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 | |
#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 "alias e=exit" >> ~/.bashrc || echo "${YELLOW}It's not possible to create the alias.${RESET}" | |
echo "alias resetk='setxkbmap -option'" >> ~/.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}" | |
[ ! -d ~/.config ] && mkdir -p ~/.config | |
git clone https://github.com/micaelviana/.dotfiles ~/.dotfiles | |
ln -sf ~/.dotfiles/neovim/.config/nvim/ ~/.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