-- nvim coding config -- Launch: NVIM_APPNAME=code nvim vim.g.mapleader = " " -- Disable netrw (snacks explorer replaces it) vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 -- Appearance vim.opt.number = true vim.opt.relativenumber = true vim.opt.signcolumn = "yes" vim.opt.termguicolors = true vim.opt.cursorline = true vim.opt.showmode = false vim.opt.laststatus = 2 vim.opt.fillchars = { eob = " " } -- Kill syntax highlighting vim.cmd("syntax off") vim.cmd("filetype plugin indent on") -- Colorscheme vim.cmd("colorscheme vacme") -- Indentation vim.opt.expandtab = true vim.opt.tabstop = 4 vim.opt.shiftwidth = 4 vim.opt.smartindent = true vim.opt.autoindent = true -- Search vim.opt.ignorecase = true vim.opt.smartcase = true vim.opt.hlsearch = false vim.opt.incsearch = true -- Wrapping vim.opt.wrap = false vim.opt.scrolloff = 8 vim.opt.sidescrolloff = 8 -- Misc vim.opt.swapfile = false vim.opt.backup = false vim.opt.undofile = true vim.opt.undodir = vim.fn.stdpath("data") .. "/undo" vim.opt.clipboard = "unnamedplus" vim.opt.mouse = "a" vim.opt.updatetime = 250 -- snacks.nvim (explorer + project picker + dashboard) require("snacks").setup({ explorer = { enabled = true }, picker = { enabled = true, sources = { projects = { dev = { "~/dev" }, recent = false, }, }, }, dashboard = { enabled = true, preset = { header = (function() local f = io.open(vim.fn.stdpath("config") .. "/glenda.txt", "r") if f then local s = f:read("*a"); f:close(); return s end return "code" end)(), keys = { { icon = " ", key = "f", desc = "Find File", action = ":lua Snacks.dashboard.pick('files')" }, { icon = " ", key = "n", desc = "New File", action = ":ene | startinsert" }, { icon = " ", key = "g", desc = "Find Text", action = ":lua Snacks.dashboard.pick('live_grep')" }, { icon = " ", key = "r", desc = "Recent Files", action = ":lua Snacks.dashboard.pick('oldfiles')" }, { icon = " ", key = "s", desc = "Browse src", action = ":e ~/.local/src/" }, { icon = " ", key = "b", desc = "Browse scripts", action = ":e ~/.local/bin/" }, { icon = " ", key = "i", desc = "mkshrc", action = ":e ~/.mkshrc" }, { icon = " ", key = "p", desc = "plan9rc", action = ":e ~/.planrc" }, { icon = " ", key = "a", desc = "aliases.sh", action = ":e ~/.config/mksh/aliases.sh" }, { icon = " ", key = "u", desc = "functions.sh", action = ":e ~/.config/mksh/functions.sh" }, { icon = " ", key = "e", desc = "Explorer", action = ":lua Snacks.explorer.open()" }, { icon = " ", key = "q", desc = "Quit", action = ":qa" }, }, }, sections = { { section = "header" }, { section = "keys", gap = 1, padding = 1 }, }, }, }) -- gitsigns require("gitsigns").setup({ signs = { add = { text = "+" }, change = { text = "~" }, delete = { text = "_" }, topdelete = { text = "-" }, changedelete = { text = "~" }, }, }) -- lualine (statusline) require("lualine").setup({ options = { theme = { normal = { a = { fg = "#424242", bg = "#EAFFFF", gui = "bold" }, b = { fg = "#424242", bg = "#EAEBDB" }, c = { fg = "#424242", bg = "#FFFFEC" }, }, insert = { a = { fg = "#424242", bg = "#EFFEEC", gui = "bold" }, }, visual = { a = { fg = "#424242", bg = "#EEEEA7", gui = "bold" }, }, command = { a = { fg = "#424242", bg = "#D0D0F7", gui = "bold" }, }, inactive = { c = { fg = "#999957", bg = "#FFFFEC" }, }, }, icons_enabled = false, component_separators = { left = "|", right = "|" }, section_separators = { left = "", right = "" }, }, sections = { lualine_a = { "mode" }, lualine_b = { "branch" }, lualine_c = { "filename" }, lualine_x = { "filetype" }, lualine_y = { "progress" }, lualine_z = { "location" }, }, }) -- Keymaps local map = vim.keymap.set -- Explorer map("n", "e", function() Snacks.explorer.open() end, { desc = "Toggle file explorer" }) -- Project switcher (browse ~/dev directories) map("n", "fp", function() local dev_root = vim.fn.expand("~/dev") Snacks.picker.files({ cwd = dev_root, cmd = "fd", args = { "--type", "d", "--max-depth", "1" }, confirm = function(picker, item) picker:close() if item then local dir = dev_root .. "/" .. item.text:gsub("/$", "") vim.cmd("cd " .. vim.fn.fnameescape(dir)) Snacks.picker.files({ cwd = dir }) end end, }) end, { desc = "Switch project" }) -- File search map("n", "sf", function() Snacks.picker.files() end, { desc = "Search files" }) map("n", "fg", function() Snacks.picker.grep() end, { desc = "Grep" }) map("n", "ff", function() Snacks.picker.smart() end, { desc = "Smart find" }) map("n", "s.", function() Snacks.picker.recent() end, { desc = "Recent files" }) map("n", "", function() Snacks.picker.buffers() end, { desc = "Buffers" }) map("n", "/", function() Snacks.picker.lines() end, { desc = "Search in buffer" }) -- Basics map("n", "w", "w", { desc = "Save" }) map("n", "q", "q", { desc = "Quit" })