#!/bin/bash NO_FORMAT="\033[0m" C_RED="\033[38;5;9m" C_LIME="\033[38;5;10m" NVIM_CONFIG=$HOME/.config/nvim/ function main () { if [ "$EUID" -eq 0 ] then echo -e "${C_RED}Script cannot be run as root !${NO_FORMAT}" exit fi mkdir -p /tmp/nvchad-installer/ check_and_install_nvim check_and_install_nerdfont check_and_install_nvchad customize_nvim cleanup echo -e "${C_LIME}Script has finished running ! Please run source ~/.bashrc or reopen your terminal !${NO_FORMAT}" } check_wget () { if ! command -v "wget" > /dev/null; then echo "wget is required to use the script" exit fi } check_and_install_nvim () { if command -v "nvim" > /dev/null then echo "Neovim is already installed on your system, skipping installation" else # Nvim download check_wget echo "Downloading latest neovim release..." wget -q --show-progress https://github.com/neovim/neovim/releases/latest/download/nvim.appimage -P /tmp/nvchad-installer/ # Update $PATH echo "Adding ~/.local/bin to your \$PATH..." export PATH=$HOME/.local/bin:$PATH echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrc # Move nvim to PATH echo "Placing nvim appimage in ~/.local/bin/..." mkdir -p ~/.local/bin/ chmod +x /tmp/nvchad-installer/nvim.appimage mv /tmp/nvchad-installer/nvim.appimage ~/.local/bin/nvim echo -e "${C_LIME}Neovim is now installed !${NO_FORMAT}" fi } check_and_install_nerdfont () { FILE=$HOME/.fonts/JetBrainsMonoNLNerdFont-Regular.ttf if [ -f "$FILE" ]; then echo "$FILE already exists, skipping installation..." else check_wget echo "Downloading JetBrainsMono Nerd font..." wget -q --show-progress https://github.com/ryanoasis/nerd-fonts/releases/latest/download/JetBrainsMono.zip -P /tmp/nvchad-installer/ echo "Unzipping JetBrainsMono Nerd font..." unzip -j "/tmp/nvchad-installer/JetBrainsMono.zip" "JetBrainsMonoNLNerdFont-Regular.ttf" -d "/tmp/nvchad-installer/" echo "Installing the NerdFont..." mkdir -p ~/.fonts mv /tmp/nvchad-installer/JetBrainsMonoNLNerdFont-Regular.ttf ~/.fonts echo -e "${C_LIME}JetBrainsMono NerdFont is now installed !${NO_FORMAT}" read -p "To enable the Nerd font, open terminal preferences and set the font to JetBrainsMono Nerd Font (Press Enter when done)" fi } check_and_install_nvchad () { if [ -d "$NVIM_CONFIG" ]; then echo "$NVIM_CONFIG already exists, skipping installation..." else echo "Installing NvChad..." git clone https://github.com/NvChad/starter $NVIM_CONFIG read -p "Neovim is about to launch. After it has finished installing plugins, it should automatically exit ! (Press Enter to continue)" nvim +MasonInstallAll +qall echo -e "${C_LIME}NvChad is now installed !${NO_FORMAT}" fi } customize_nvim () { if [ -f /tmp/nvchad-installer/JetBrainsMono.zip ]; then echo "Looks like Neovim is already customized, skipping customization" else echo MASON_CONFIG > $NVIM_CONFIG/lua/plugins/custom.lua echo -e "${C_LIME}Neovim is now customizes !${NO_FORMAT}" fi } cleanup () { [ -f /tmp/nvchad-installer/JetBrainsMono.zip ] && { echo "Removing JetBrainsMono font zipfile..."; rm /tmp/nvchad-installer/JetBrainsMono.zip; } } MASON_CONFIG = 'return { { "williamboman/mason.nvim", opts = { ensure_installed = { "lua-language-server", "stylua", "html-lsp", "css-lsp" , "prettier", "clangd", "clang-format" }, }, }, }' main