140 lines
3.9 KiB
Bash
140 lines
3.9 KiB
Bash
#!/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 +MasonInstall +"MasonInstall clangd" +qall
|
|
|
|
echo -e "${C_LIME}NvChad is now installed !${NO_FORMAT}"
|
|
fi
|
|
}
|
|
|
|
LSPCONFIG='require("nvchad.configs.lspconfig").defaults()
|
|
|
|
local lspconfig = require "lspconfig"
|
|
local servers = { "html", "cssls", "clangd" }
|
|
local nvlsp = require "nvchad.configs.lspconfig"
|
|
|
|
for _, lsp in ipairs(servers) do
|
|
lspconfig[lsp].setup {
|
|
on_attach = nvlsp.on_attach,
|
|
on_init = nvlsp.on_init,
|
|
capabilities = nvlsp.capabilities,
|
|
}
|
|
end'
|
|
|
|
customize_nvim ()
|
|
{
|
|
if ! [[ echo "9c3bf1ed3d48d091bf791f1b923493f3e5ecf723 $NVIM_CONFIG/lua/custom/configs/lspconfig.lua" | sha1sum -c - ]]; then
|
|
echo "Looks like Neovim is already customized, skipping customization"
|
|
else
|
|
echo $LSPCONFIG > $NVIM_CONFIG/lua/configs/lspconfig.lua
|
|
echo -e "${C_LIME}Neovim is now customized !${NO_FORMAT}"
|
|
fi
|
|
}
|
|
|
|
cleanup ()
|
|
{
|
|
[ -f /tmp/nvchad-installer/JetBrainsMono.zip ] && {
|
|
echo "Removing JetBrainsMono font zipfile...";
|
|
rm /tmp/nvchad-installer/JetBrainsMono.zip;
|
|
}
|
|
}
|
|
|
|
|
|
main
|