From 978803fd262a9d75efd6fd4a1dcab0a8c29d5813 Mon Sep 17 00:00:00 2001 From: Adam Bellinson Date: Fri, 27 Feb 2026 12:38:34 -0500 Subject: [PATCH] snacks and other things from work --- lua/mappings.lua | 10 +-- lua/mappings_nvchad.lua | 109 +++++++++++++++++++++++++ lua/plugins/init.lua | 10 +-- lua/plugins/snacks.lua | 163 ++++++++++++++++++++++++++++++++++++++ lua/plugins/telescope.lua | 6 ++ 5 files changed, 288 insertions(+), 10 deletions(-) create mode 100644 lua/mappings_nvchad.lua create mode 100644 lua/plugins/snacks.lua create mode 100644 lua/plugins/telescope.lua diff --git a/lua/mappings.lua b/lua/mappings.lua index dea258e..937c627 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -1,4 +1,4 @@ -require "nvchad.mappings" +require "mappings_nvchad" -- add yours here @@ -27,7 +27,7 @@ map("n", "l", "l", { desc = "Focus right split" }) -- File operations map("n", "ee", ':e =expand("%:p:h" . "/" )', { desc = "Copy relative path to file" }) map("n", "er", ":!echo -n % | pbcopy", { desc = "Copy absolute path to file" }) -map("n", "gn", ":Telescope resume", { desc = "Resume telescope" }) +-- map("n", "gn", ":Telescope resume", { desc = "Resume telescope" }) map("n", "eu", '!!python -c "import uuid; print(uuid.uuid4())"', { desc = "Drop fresh uuid4" }) -- Clipboard operations @@ -47,11 +47,11 @@ map("n", "N", " set nu! ", { desc = "Toggle line number" }) map("n", "x", "bdelete", { desc = "Close Buffer and window" }) map("n", "X", "bdelete!", { desc = "Close Buffer and window!" }) map("n", "c", "Bdelete", { desc = "Close Buffer" }) -map("n", "b", " Telescope buffers ", { desc = "Find buffers" }) +-- map("n", "b", " Telescope buffers ", { desc = "Find buffers" }) -- Git operations -map("n", "gb", "Gitsigns blame", { desc = "Git blame" }) -map("n", "gB", "Gitsigns blame_line", { desc = "Git blame line" }) +map("n", "gm", "Gitsigns blame", { desc = "Git blame" }) +map("n", "gM", "Gitsigns blame_line", { desc = "Git blame line" }) map("n", "gu", "diffget //2", { desc = "Select left in conflict" }) map("n", "gh", "diffget //3", { desc = "Select right in conflict" }) diff --git a/lua/mappings_nvchad.lua b/lua/mappings_nvchad.lua new file mode 100644 index 0000000..72a078a --- /dev/null +++ b/lua/mappings_nvchad.lua @@ -0,0 +1,109 @@ +local map = vim.keymap.set + +map("i", "", "^i", { desc = "move beginning of line" }) +map("i", "", "", { desc = "move end of line" }) +map("i", "", "", { desc = "move left" }) +map("i", "", "", { desc = "move right" }) +map("i", "", "", { desc = "move down" }) +map("i", "", "", { desc = "move up" }) + +map("n", "", "h", { desc = "switch window left" }) +map("n", "", "l", { desc = "switch window right" }) +map("n", "", "j", { desc = "switch window down" }) +map("n", "", "k", { desc = "switch window up" }) + +map("n", "", "noh", { desc = "general clear highlights" }) + +map("n", "", "w", { desc = "general save file" }) +map("n", "", "%y+", { desc = "general copy whole file" }) + +map("n", "n", "set nu!", { desc = "toggle line number" }) +map("n", "rn", "set rnu!", { desc = "toggle relative number" }) +map("n", "ch", "NvCheatsheet", { desc = "toggle nvcheatsheet" }) + +map({ "n", "x" }, "fm", function() + require("conform").format { lsp_fallback = true } +end, { desc = "general format file" }) + +-- global lsp mappings +map("n", "ds", vim.diagnostic.setloclist, { desc = "LSP diagnostic loclist" }) + +-- tabufline +if require("nvconfig").ui.tabufline.enabled then + map("n", "b", "enew", { desc = "buffer new" }) + + map("n", "", function() + require("nvchad.tabufline").next() + end, { desc = "buffer goto next" }) + + map("n", "", function() + require("nvchad.tabufline").prev() + end, { desc = "buffer goto prev" }) + + map("n", "x", function() + require("nvchad.tabufline").close_buffer() + end, { desc = "buffer close" }) +end + +-- Comment +map("n", "/", "gcc", { desc = "toggle comment", remap = true }) +map("v", "/", "gc", { desc = "toggle comment", remap = true }) + +-- nvimtree +map("n", "", "NvimTreeToggle", { desc = "nvimtree toggle window" }) +map("n", "e", "NvimTreeFocus", { desc = "nvimtree focus window" }) + +-- telescope +-- map("n", "fw", "Telescope live_grep", { desc = "telescope live grep" }) +-- map("n", "fb", "Telescope buffers", { desc = "telescope find buffers" }) +-- map("n", "fh", "Telescope help_tags", { desc = "telescope help page" }) +-- map("n", "ma", "Telescope marks", { desc = "telescope find marks" }) +-- map("n", "fo", "Telescope oldfiles", { desc = "telescope find oldfiles" }) +-- map("n", "fz", "Telescope current_buffer_fuzzy_find", { desc = "telescope find in current buffer" }) +-- map("n", "cm", "Telescope git_commits", { desc = "telescope git commits" }) +-- map("n", "gt", "Telescope git_status", { desc = "telescope git status" }) +-- map("n", "pt", "Telescope terms", { desc = "telescope pick hidden term" }) +-- +-- map("n", "th", function() +-- require("nvchad.themes").open() +-- end, { desc = "telescope nvchad themes" }) +-- +-- map("n", "ff", "Telescope find_files", { desc = "telescope find files" }) +-- map( +-- "n", +-- "fa", +-- "Telescope find_files follow=true no_ignore=true hidden=true", +-- { desc = "telescope find all files" } +-- ) + +-- terminal +map("t", "", "", { desc = "terminal escape terminal mode" }) + +-- new terminals +map("n", "h", function() + require("nvchad.term").new { pos = "sp" } +end, { desc = "terminal new horizontal term" }) + +map("n", "v", function() + require("nvchad.term").new { pos = "vsp" } +end, { desc = "terminal new vertical term" }) + +-- toggleable +map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm" } +end, { desc = "terminal toggleable vertical term" }) + +map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm" } +end, { desc = "terminal toggleable horizontal term" }) + +map({ "n", "t" }, "", function() + require("nvchad.term").toggle { pos = "float", id = "floatTerm" } +end, { desc = "terminal toggle floating term" }) + +-- whichkey +map("n", "wK", "WhichKey ", { desc = "whichkey all keymaps" }) + +map("n", "wk", function() + vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ") +end, { desc = "whichkey query lookup" }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3ce6e39..c1ccc25 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -29,11 +29,11 @@ return { dialyzerEnabled = false, enableTestLenses = false, }, - on_attach = function(client, bufnr) - vim.keymap.set("n", "fp", ":ElixirFromPipe", { buffer = true, noremap = true }) - vim.keymap.set("n", "tp", ":ElixirToPipe", { buffer = true, noremap = true }) - vim.keymap.set("v", "em", ":ElixirExpandMacro", { buffer = true, noremap = true }) - end, + -- on_attach = function(client, bufnr) + -- vim.keymap.set("n", "fp", ":ElixirFromPipe", { buffer = true, noremap = true }) + -- vim.keymap.set("n", "tp", ":ElixirToPipe", { buffer = true, noremap = true }) + -- vim.keymap.set("v", "em", ":ElixirExpandMacro", { buffer = true, noremap = true }) + -- end, }, } end, diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua new file mode 100644 index 0000000..cca1746 --- /dev/null +++ b/lua/plugins/snacks.lua @@ -0,0 +1,163 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + bigfile = { enabled = true }, + dashboard = { enabled = true }, + explorer = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + notifier = { + enabled = true, + timeout = 3000, + }, + picker = { enabled = true, layout = "ivy_split" }, + quickfile = { enabled = true }, + scope = { enabled = true }, + scroll = { enabled = false }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + styles = { + notification = { + -- wo = { wrap = true } -- Wrap notifications + } + } + }, + keys = { + -- Top Pickers & Explorer + { "", function() Snacks.picker.smart() end, desc = "Smart Find Files" }, + { ",", function() Snacks.picker.buffers() end, desc = "Buffers" }, + { "/", function() Snacks.picker.grep() end, desc = "Grep" }, + { ":", function() Snacks.picker.command_history() end, desc = "Command History" }, + { "n", function() Snacks.picker.notifications() end, desc = "Notification History" }, + { "e", function() Snacks.explorer() end, desc = "File Explorer" }, + -- find + { "fb", function() Snacks.picker.buffers() end, desc = "Buffers" }, + { "fc", function() Snacks.picker.files({ cwd = vim.fn.stdpath("config") }) end, desc = "Find Config File" }, + { "ff", function() Snacks.picker.files() end, desc = "Find Files" }, + { "fg", function() Snacks.picker.git_files() end, desc = "Find Git Files" }, + { "fp", function() Snacks.picker.projects() end, desc = "Projects" }, + { "fr", function() Snacks.picker.recent() end, desc = "Recent" }, + -- git + { "gb", function() Snacks.picker.git_branches() end, desc = "Git Branches" }, + { "gl", function() Snacks.picker.git_log() end, desc = "Git Log" }, + { "gL", function() Snacks.picker.git_log_line() end, desc = "Git Log Line" }, + { "gs", function() Snacks.picker.git_status() end, desc = "Git Status" }, + { "gS", function() Snacks.picker.git_stash() end, desc = "Git Stash" }, + { "gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (Hunks)" }, + { "gf", function() Snacks.picker.git_log_file() end, desc = "Git Log File" }, + -- gh + { "gi", function() Snacks.picker.gh_issue() end, desc = "GitHub Issues (open)" }, + { "gI", function() Snacks.picker.gh_issue({ state = "all" }) end, desc = "GitHub Issues (all)" }, + { "gp", function() Snacks.picker.gh_pr() end, desc = "GitHub Pull Requests (open)" }, + { "gP", function() Snacks.picker.gh_pr({ state = "all" }) end, desc = "GitHub Pull Requests (all)" }, + -- Grep + { "sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" }, + { "sB", function() Snacks.picker.grep_buffers() end, desc = "Grep Open Buffers" }, + { "sg", function() Snacks.picker.grep() end, desc = "Grep" }, + { "sw", function() Snacks.picker.grep_word() end, desc = "Visual selection or word", mode = { "n", "x" } }, + -- search + { 's"', function() Snacks.picker.registers() end, desc = "Registers" }, + { 's/', function() Snacks.picker.search_history() end, desc = "Search History" }, + { "sa", function() Snacks.picker.autocmds() end, desc = "Autocmds" }, + { "sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" }, + { "sc", function() Snacks.picker.command_history() end, desc = "Command History" }, + { "sC", function() Snacks.picker.commands() end, desc = "Commands" }, + { "sd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" }, + { "sD", function() Snacks.picker.diagnostics_buffer() end, desc = "Buffer Diagnostics" }, + { "sh", function() Snacks.picker.help() end, desc = "Help Pages" }, + { "sH", function() Snacks.picker.highlights() end, desc = "Highlights" }, + { "si", function() Snacks.picker.icons() end, desc = "Icons" }, + { "sj", function() Snacks.picker.jumps() end, desc = "Jumps" }, + { "sk", function() Snacks.picker.keymaps() end, desc = "Keymaps" }, + { "sl", function() Snacks.picker.loclist() end, desc = "Location List" }, + { "sm", function() Snacks.picker.marks() end, desc = "Marks" }, + { "sM", function() Snacks.picker.man() end, desc = "Man Pages" }, + { "sp", function() Snacks.picker.lazy() end, desc = "Search for Plugin Spec" }, + { "sq", function() Snacks.picker.qflist() end, desc = "Quickfix List" }, + { "sR", function() Snacks.picker.resume() end, desc = "Resume" }, + { "su", function() Snacks.picker.undo() end, desc = "Undo History" }, + { "uC", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" }, + -- LSP + { "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition" }, + { "gD", function() Snacks.picker.lsp_declarations() end, desc = "Goto Declaration" }, + { "gr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" }, + { "gI", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" }, + { "gy", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" }, + { "gai", function() Snacks.picker.lsp_incoming_calls() end, desc = "C[a]lls Incoming" }, + { "gao", function() Snacks.picker.lsp_outgoing_calls() end, desc = "C[a]lls Outgoing" }, + { "ss", function() Snacks.picker.lsp_symbols() end, desc = "LSP Symbols" }, + { "sS", function() Snacks.picker.lsp_workspace_symbols() end, desc = "LSP Workspace Symbols" }, + -- Other + { "z", function() Snacks.zen() end, desc = "Toggle Zen Mode" }, + { "Z", function() Snacks.zen.zoom() end, desc = "Toggle Zoom" }, + { ".", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" }, + { "S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" }, + { "n", function() Snacks.notifier.show_history() end, desc = "Notification History" }, + { "bd", function() Snacks.bufdelete() end, desc = "Delete Buffer" }, + { "cR", function() Snacks.rename.rename_file() end, desc = "Rename File" }, + { "gB", function() Snacks.gitbrowse() end, desc = "Git Browse", mode = { "n", "v" } }, + { "gg", function() Snacks.lazygit() end, desc = "Lazygit" }, + { "un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" }, + { "", function() Snacks.terminal() end, desc = "Toggle Terminal" }, + { "", function() Snacks.terminal() end, desc = "which_key_ignore" }, + { "]]", function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference", mode = { "n", "t" } }, + { "[[", function() Snacks.words.jump(-vim.v.count1) end, desc = "Prev Reference", mode = { "n", "t" } }, + { + "N", + desc = "Neovim News", + function() + Snacks.win({ + file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1], + width = 0.6, + height = 0.6, + wo = { + spell = false, + wrap = false, + signcolumn = "yes", + statuscolumn = " ", + conceallevel = 3, + }, + }) + end, + } + }, + init = function() + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + + -- Override print to use snacks for `:=` command + if vim.fn.has("nvim-0.11") == 1 then + vim._print = function(_, ...) + dd(...) + end + else + vim.print = _G.dd + end + + -- Create some toggle mappings + Snacks.toggle.option("spell", { name = "Spelling" }):map("us") + Snacks.toggle.option("wrap", { name = "Wrap" }):map("uw") + Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("uL") + Snacks.toggle.diagnostics():map("ud") + Snacks.toggle.line_number():map("ul") + Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("uc") + Snacks.toggle.treesitter():map("uT") + Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark Background" }):map("ub") + Snacks.toggle.inlay_hints():map("uh") + Snacks.toggle.indent():map("ug") + Snacks.toggle.dim():map("uD") + end, + }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..68063c1 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,6 @@ +return { + { + "nvim-telescope/telescope.nvim", + enabled = false, + }, +}