#!/bin/bash
# - bof - #



<<'comment'

# -  - #
# - File name - #
neoVim-nvChad.sh

bash <(curl -s https://www.education.isdevelopment.us/neoVim-nvChad/01-neoVim-nvChad.sh)



cd ~/; rm -rf ~/NvChad_.sh; vim ~/NvChad_.sh;
copy & paste this content
chmod +x ~/NvChad_.sh; ~/./NvChad_.sh;

ssh-keygen -R 192.168.1.1

# - On client - #
cd ~/.ssh;
ssh-keygen -t rsa;

cat ~/.ssh/id_rsa.pub;

# - On server - #
vim ~/.ssh/authorized_keys;

sudo apt install curl git inxi net-tools ntp neovim -y;
sudo apt install curl git ifupdown2 inxi net-tools ntp neovim -y;

# -  - #
# - Documentation - #
https://www.youtube.com/watch?v=yW3ovyQCwpw
https://nvchad.com/
https://github.com/NvChad/NvChad
https://nvchad.com/docs/quickstart/install/

comment



# -  - #
# - InstallNeoVim_ - #
function InstallNeoVim_(){
  echo -e "\n\n\nInstalling neovim & dependencies...\n\n";
  update_;
  case $Opt in
    1 | 4 | 5 )
      echo -e "\nInstalling neovim...\n\n";
      # - ubuntu, debian, linuxmint, zorin - #
      sudo apt install -y neovim git unzip luarocks xclip wl-clipboard ripgrep fd-find;
      ;;
    2 )
      # - arch - #
      sudo pacman -S --noconfirm --needed neovim git unzip luarocks xclip wl-clipboard ripgrep fd;
      ;;
    3 )
      # - fedora - #
      sudo dnf install -y neovim git unzip luarocks xclip wl-clipboard ripgrep fd-find;
      ;;
  esac
}



# -  - #
# - RemoveNvChad_ - #
function RemoveNvChad_(){
  echo -e "\nRemoving previous nvim config...\n";
  rm -rf ~/.config/nvim;
  rm -rf ~/.local/share/nvim;
  rm -rf ~/.local/state/nvim;
  echo -e "Previous nvim configuration removed.\n";
  sleep 2;
}



# -  - #
# - InstallNvChad_ - #
function InstallNvChad_(){
  echo -e "\nInstalling NvChad...\n";
  git clone https://github.com/NvChad/starter ~/.config/nvim;
  echo -e "\n\nNvChad installed. Run nvim to complete setup.\n";
  sleep 2;
}



# -  - #
# - ConfigureNvChad_ - #
function ConfigureNvChad_(){
  local nvimConfigDir="$HOME/.config/nvim"
  local chadrcFile="$nvimConfigDir/lua/chadrc.lua"
  local pluginsFile="$nvimConfigDir/lua/plugins/init.lua"

  echo -e "\nSetting up NvChad custom configuration...\n"

  mkdir -p "$nvimConfigDir/lua/plugins"

  # 1. Configure chadrc.lua with ayu_dark theme
  tee "$chadrcFile" << 'EOF' > /dev/null
-- This file needs to have same structure as nvconfig.lua 
-- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua
-- Please read that file to know all available options :( 

---@type ChadrcConfig
local M = {}

M.base46 = {
  theme = "ayu_dark",
}

return M
EOF

  # 2. Configure plugins/init.lua with common language support
  tee "$pluginsFile" << 'EOF' > /dev/null
return {
  {
    "stevearc/conform.nvim",
    -- event = 'BufWritePre', -- uncomment for format on save
    opts = require "configs.conform",
  },

  {
    "neovim/nvim-lspconfig",
    config = function()
      require "configs.lspconfig"
    end,
  },

  {
    "nvim-treesitter/nvim-treesitter",
    opts = {
      ensure_installed = {
        "vim", "lua", "vimdoc", "html", "css", "toml",
        "bash", "python", "json", "yaml", "markdown",
      },
    },
  },
}
EOF

  echo -e "NvChad custom configuration written successfully.\n"
  sleep 2
}



<<'comment'


# -  - #
# - nvChad Installation Steps - #

# 1. Remove old config
rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.local/state/nvim

# 2. Install neovim
sudo pacman -S neovim unzip luarocks xclip wl-clipboard --noconfirm --needed;
sudo apt install -y neovim git unzip luarocks xclip wl-clipboard ripgrep fd-find;

# 3. Clone NvChad starter
git clone https://github.com/NvChad/starter ~/.config/nvim && nvim;

# 4. Inside nvim run:
:MasonInstallAll
:q

# 5. Set theme
# In nvim: Space + t + h → Select "ayu_dark"

# 6. Configure chadrc.lua
nvim ~/.config/nvim/lua/chadrc.lua;
# Set theme = "ayu_dark"

# 7. Configure plugins
nvim ~/.config/nvim/lua/plugins/init.lua;


# -  - #
# - nvChad unInstallation - #
rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.local/state/nvim


# -  - #
# - nvChad Documentation - #
https://nvchad.com/docs/quickstart/install/
https://github.com/NvChad/NvChad


# -  - #
# - Pre-requisites - #
Nerd Font: https://www.nerdfonts.com/

comment



clear;

source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)
distroVersion_;

InstallNeoVim_;
RemoveNvChad_;
InstallNvChad_;
ConfigureNvChad_;



rm -rf $NvChad_.sh;

echo -e "\n\nNvChad has been installed successfully!\n";
echo -e "Run 'nvim' to complete the setup (MasonInstallAll will run automatically).\n";
echo -e "After setup, press Space + t + h and select 'ayu_dark' theme.\n\n\n";
sleep 5;



<<'comment'
cd ~/; rm -rf ~/NvChad_.sh; vim ~/NvChad_.sh;
copy & paste this content
chmod +x ~/NvChad_.sh; ~/./NvChad_.sh;

ssh-keygen -R 192.168.1.1
~/./NvChad_.sh;
comment



# - eof - #