scripts/nvim-install.sh
2026-01-10 14:43:00 +03:00

65 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Step 0. Detect the OS
if [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
elif [[ -f /etc/os-release ]]; then
# shellcheck disable=SC1091
. /etc/os-release
case "$ID" in
ubuntu|pop|linuxmint|zorin|elementary|kdeneon)
OS="ubuntu"
;;
arch|manjaro|endeavouros|garuda|artix)
OS="arch"
;;
*)
err "Unsupported Linux distribution: $ID"
exit 1
;;
esac
else
err "Cannot determine OS."
exit 1
fi
echo "🔎 Determined OS: $OS"
# Step 1: Install Neovim
if [[$OS == "macos"]]; then
brew install neovim
elif [[$OS == "ubuntu"]]; then
sudo apt install neovim -y
elif [[$OS == "arch"]]; then
sudo pacman -Sy --noconfirm neovim xclip wl-clipboard
fi
echo "✅ Neovim installed"
# Step 2: Create the Neovim config directory
CONFIG_DIR = ~/.config/nvim
CONFIG = $CONFIG_DIR/init.lua
mkdir -p $CONFIG_DIR
# Step 3: Write your custom init.lua configuration
cat <<EOF > $CONFIG
vim.cmd("set expandtab")
vim.cmd("set tabstop=4")
vim.cmd("set softtabstop=4")
vim.cmd("set shiftwidth=4")
vim.cmd("set number relativenumber")
vim.cmd("highlight Normal guibg=transparent")
vim.opt.clipboard = "unnamedplus"
-- Clipboard alternative fix
vim.g.mapleader = " "
vim.keymap.set({"n", "v"}, "<leader>y", "\"+y")
vim.keymap.set({"n", "v"}, "<leader>p", "\"+p")
-- Moving lines up and down
vim.keymap.set({"n", "v"}, "<leader>u", ":m -2<Enter>")
vim.keymap.set({"n", "v"}, "<leader>d", ":m +1<Enter>")
EOF
echo "✅ Config written ($CONFIG)"
# Step 4: Notify user of success
echo "All done! You can now open Neovim with the 'nvim' command"