#!/usr/bin/env bash set -euo pipefail : "${HOME:?HOME is not set}" nvim_dir="$HOME/.config/nvim" init_file="$nvim_dir/init.lua" tmux_init="$HOME/.tmux.conf" tmux_tmp="$(mktemp "$HOME/tmux.conf.tmp.XXXXXX")" mkdir -p "$nvim_dir" if [[ -f "$init_file" ]]; then backup_file="$init_file.backup.$(date +%Y%m%d-%H%M%S)" cp -p "$init_file" "$backup_file" echo "Backed up existing init.lua to: $backup_file" fi tmp_file="$(mktemp "$nvim_dir/init.lua.tmp.XXXXXX")" cat > "$tmp_file" <<'NVIM_INIT_LUA' local ok_ui2, ui2 = pcall(require, "vim._core.ui2") if ok_ui2 and ui2.enable then ui2.enable({ enable = true, msg = { target = "cmd", pager = { height = 0.5 }, dialog = { height = 0.5 }, cmd = { height = 0.5 }, msg = { height = 0.5, timeout = 4500 }, }, }) end vim.g.mapleader = " " vim.opt.showmatch = true vim.opt.ignorecase = true vim.opt.smartcase = true vim.opt.tabstop = 4 vim.opt.softtabstop = 4 vim.opt.expandtab = true vim.opt.shiftwidth = 4 vim.opt.autoindent = true vim.opt.number = true vim.opt.relativenumber = true vim.opt.splitright = true vim.opt.splitbelow = true vim.opt.cursorline = true vim.opt.wrap = false vim.opt.completeopt = { "menuone", "noselect", "popup" } vim.opt.swapfile = true vim.opt.backup = false vim.opt.writebackup = true vim.opt.undofile = true vim.opt.termguicolors = true vim.opt.signcolumn = "yes" vim.opt.scrolloff = 4 vim.opt.sidescrolloff = 8 vim.opt.updatetime = 250 vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 vim.cmd("command! W w") vim.pack.add({ "https://github.com/nvim-tree/nvim-web-devicons", "https://github.com/EL-MASTOR/bufferlist.nvim", "https://github.com/nvim-lua/plenary.nvim", "https://github.com/mikavilpas/yazi.nvim", { src = "https://github.com/kylechui/nvim-surround", version = "v3.0.0" }, "https://github.com/stevearc/quicker.nvim", "https://github.com/folke/snacks.nvim", "https://github.com/folke/tokyonight.nvim", }) require("bufferlist").setup() require("nvim-surround").setup() require("yazi").setup({ open_for_directories = true, keymaps = { show_help = "", }, }) require("quicker").setup({ keys = { { ">", function() require("quicker").expand({ before = 2, after = 2, add_to_existing = true }) end, desc = "Expand quickfix context", }, { "<", function() require("quicker").collapse() end, desc = "Collapse quickfix context", }, }, }) require("snacks").setup({ bigfile = { enabled = true }, dashboard = { enabled = false }, indent = { enabled = true }, input = { enabled = true }, picker = { enabled = true, }, notifier = { enabled = true, filter = function(notif) if notif.title and (notif.title:find("Windsurf") or notif.title:find("Codeium")) then return false end return true end, }, quickfile = { enabled = true }, scope = { enabled = true }, scroll = { enabled = true }, statuscolumn = { enabled = true }, words = { enabled = true }, keymap = { enabled = true }, win = { enabled = true }, util = { enabled = true }, bufdelete = { enabled = true }, }) local transparent = false local bg = "#011628" local bg_dark = "#011423" local bg_highlight = "#143652" local bg_search = "#0A64AC" local bg_visual = "#275378" local fg = "#CBE0F0" local fg_dark = "#B4D0E9" local fg_gutter = "#627E97" local border = "#547998" require("tokyonight").setup({ style = "night", transparent = transparent, styles = { sidebars = transparent and "transparent" or "dark", floats = transparent and "transparent" or "dark", }, on_colors = function(colors) colors.bg = bg colors.bg_dark = transparent and colors.none or bg_dark colors.bg_float = transparent and colors.none or bg_dark colors.bg_highlight = bg_highlight colors.bg_popup = bg_dark colors.bg_search = bg_search colors.bg_sidebar = transparent and colors.none or bg_dark colors.bg_statusline = transparent and colors.none or bg_dark colors.bg_visual = bg_visual colors.border = border colors.fg = fg colors.fg_dark = fg_dark colors.fg_float = fg colors.fg_gutter = fg_gutter colors.fg_sidebar = fg_dark end, }) vim.cmd("colorscheme tokyonight") local map = vim.keymap.set map("n", "rr", "restart", { desc = "Restart Neovim" }) map("i", "jk", "", { desc = "Escape to Normal Mode" }) map("i", "", "", { desc = "Escape to Normal Mode" }) map("n", "qq", "qa!", { desc = "Force Close NVIM" }) map("n", "ww", "w", { desc = "Save File" }) map("n", "wh", "h", { desc = "Move One Pane Left" }) map("n", "wj", "j", { desc = "Move One Pane Down" }) map("n", "wk", "k", { desc = "Move One Pane Up" }) map("n", "wl", "l", { desc = "Move One Pane Right" }) map("n", "sv", "vnew", { desc = "Vertical Split"}) map("n", "sh", "new", { desc = "Horizontal Split"}) map("n", "sx", "close", { desc = "Close Split"}) map("n", "tn", "tabnew", { desc = "New Tab" }) map("n", "tx", "tabclose", { desc = "Close Tab" }) map("n", "", "tabnext", { desc = "Next Tab" }) map("n", "", "tabprevious", { desc = "Previous Tab" }) map("n", "b", "BufferList", { desc = "Open bufferlist" }) local Quicker = require("quicker") map("n", "q", function() Quicker.toggle() end, { desc = "Toggle quickfix" }) map("n", "l", function() Quicker.toggle({ loclist = true }) end, { desc = "Toggle loclist" }) map("n", "yy", "Yazi", { desc = "Open File Explorer" }) map({ "n", "v" }, "-", "Yazi", { desc = "Open yazi at the current file" }) map("n", "cw", "Yazi cwd", { desc = "Open the file manager in nvim's working directory" }) map("n", "", "Yazi toggle", { desc = "Resume the last yazi session" }) NVIM_INIT_LUA mv "$tmp_file" "$init_file" tmux_tmp="$(mktemp "$HOME/tmux.conf.tmp.XXXXXX")" cat > "$tmp_file" <<'TMUX_INIT_CONF' set -g default-terminal "xterm-256color" set -g base-index 1 setw -g pane-base-index 1 set -g mouse on set -g status-style "bg=blue fg=black bold" set -g automatic-rename off # Pane background / default terminal background set -g window-style "bg=black" set -g window-active-style "bg=black" set-window-option -g mode-keys vi bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R bind S command-prompt -p "New Session:" "new-session -d -A -s '%%'" bind K command-prompt -p "Kill session:" "confirm-before -p 'Kill session %1? (y/n)' \"kill-session -t '%1'\"" bind U attach-session -c "#{pane_current_path}" bind | split-window -h -c "#{pane_current_path}" bind _ split-window -v -c "#{pane_current_path}" bind r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded" TMUX_INIT_CONF mv "$tmux_tmp" "$tmux_init" echo "Wrote Neovim & Tmux Configs"