From 23126290f38f8efb276d1d4c81d25b32155f1a20 Mon Sep 17 00:00:00 2001 From: Seth Etter Date: Sun, 28 Dec 2025 21:29:47 -0600 Subject: [PATCH] nvim: drop whichkey, add trouble --- nvim/lazy-lock.json | 2 + nvim/lua/config/keys.lua | 274 ++++++++++++++++-------------------- nvim/lua/plugins/config.lua | 13 +- nvim/lua/plugins/lsp.lua | 12 ++ nvim/lua/plugins/ui.lua | 12 -- 5 files changed, 146 insertions(+), 167 deletions(-) diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index d5f9055..107eff2 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -7,6 +7,7 @@ "gitlinker.nvim": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, "gitsigns.nvim": { "branch": "main", "commit": "130beacf8a51f00aede9c31064c749136679a321" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "4cfe411526a7a99c18281135e8b4765ae6330d15" }, "mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" }, @@ -23,6 +24,7 @@ "schemastore.nvim": { "branch": "main", "commit": "60f1b3d1bde39396cdfb1362dd207970ec57e731" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, + "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/nvim/lua/config/keys.lua b/nvim/lua/config/keys.lua index ed8363b..46cf45e 100644 --- a/nvim/lua/config/keys.lua +++ b/nvim/lua/config/keys.lua @@ -1,5 +1,3 @@ -local wk = require("which-key") - local function qflist_is_open() local is_open = false for _, win in ipairs(vim.fn.getwininfo()) do @@ -10,6 +8,7 @@ local function qflist_is_open() end return is_open end + local function toggle_qf_list() if qflist_is_open() then vim.cmd("cclose") @@ -18,153 +17,124 @@ local function toggle_qf_list() end end -wk.add({ - { "", "h", desc = "Move focus to left pane" }, - { "", "j", desc = "Move focus to below pane" }, - { "", "k", desc = "Move focus to above pane" }, - { "", "l", desc = "Move focus to right pane" }, - - { "", "5zh", desc = "Scroll left" }, - { "", "5zl", desc = "Scroll right" }, - - { "H", ":bp", desc = "Switch to previous buffer" }, - { "L", ":bn", desc = "Switch to next buffer" }, - - -- Prevents the pane from being removed when closing a buffer - { "d", "bpspbnbd", desc = "Close buffer" }, - { "D", "bpspbnbd!", desc = "Close buffer (force)" }, - -- { "d", "bd", desc = "Close buffer" }, - -- { "D", "bd!", desc = "Close buffer (force)" }, - { "BD", "bufdo bd", desc = "Close all buffers" }, - - { "n", "vnew", desc = "New buffer" }, - - { "", "tabnext", desc = "Next tab", group = "tab" }, - { "tn", "tabnew", desc = "New Tab", group = "tab" }, - { "td", "tabclose", desc = "Close Tab", group = "tab" }, - - { "LC", "ConfigLocalEdit", desc = "Edit local nvim config" }, - -- { "N", "vsple NOTES.sethetter.md", desc = "Open personal notes" }, - { "N", "e NOTES.sethetter.md", desc = "Open personal notes" }, - - { - "/", - "CommentToggle", - desc = "Toggle comment", - mode = { "n" }, - }, - { - "/", - ":'<,'>CommentToggle", - desc = "Toggle comment", - mode = { "v" }, - }, - - -- { "E", "Neotree position=current toggle reveal", desc = "Open file explorer" }, - { "E", "Neotree toggle reveal position=current", desc = "Open file explorer" }, - { "e", "Neotree toggle position=current", desc = "Open file explorer" }, - -- { "E", "Neotree focus reveal position=current", desc = "Open file explorer" }, - - { "h", "noh", desc = "Clear highlight" }, - { "v/", "vsp", desc = "Split vertical", group = "split" }, - { "v?", "sp", desc = "Split horizontal", group = "split" }, - - { - "f", - "Telescope find_files find_command=rg,--ignore,--hidden,--files,--iglob=!.git sort_mru=true", - desc = "Find files", - }, - { "b", "Telescope buffers", desc = "Buffers" }, - { "sp", "Telescope live_grep", desc = "Live grep" }, - { "sh", "Telescope help_tags", desc = "Help tags" }, - { "sc", "Telescope commands", desc = "Commands" }, - - { - "cl", - toggle_qf_list, - desc = "Toggle quickfix list", - group = "quickfix", - }, - { "cn", "cnext", desc = "Next QF item", group = "quickfix" }, - { "cp", "cprev", desc = "Prev QF item", group = "quickfix" }, - - { - "m", - function() - vim.diagnostic.setqflist({ open = true, focus = true }) - end, - desc = "Diagnostics in qf list", - }, - - { "M", "messages", desc = "Messages" }, - - { "T", ":term ", desc = "Run a terminal command" }, - - { "o", "AerialToggle", desc = "Symbols outline" }, - - { "Z", "Goyo", desc = "Goyo toggle" }, - - { "w", "w", desc = "Save" }, - { "X", "x", desc = "Save and close" }, - { "q", "q", desc = "Quit" }, - { "Q", "qa", desc = "Quit all" }, - - { - "y", - function() - local filepath = vim.fn.expand('%:.') - local line = vim.fn.line('.') - local ref = filepath .. ':' .. line - vim.fn.system('pbcopy', ref) - vim.notify('Copied: ' .. ref, vim.log.levels.INFO) - end, - desc = "Copy filepath:line to clipboard" - }, - - { "[d", "lua vim.diagnostic.goto_prev()", desc = "Previous diagnostic" }, - { "]d", "lua vim.diagnostic.goto_next()", desc = "Next diagnostic" }, - { "[g", "Gitsigns prev_hunk", desc = "Previous change" }, - { "]g", "Gitsigns next_hunk", desc = "Next change" }, - - { "K", "lua vim.lsp.buf.hover()", desc = "Hover" }, - - { "g", group = "goto" }, - { "gs", "Telescope lsp_document_symbols", desc = "Document symbols" }, - { "gS", "Telescope lsp_dynamic_workspace_symbols", desc = "Workspace symbols" }, - { "gD", "lua vim.lsp.buf.declaration()", desc = "Declaration" }, - { "gd", "lua vim.lsp.buf.definition()", desc = "Definition" }, - { "gi", "lua vim.lsp.buf.implementation()", desc = "Implementation" }, - { "gr", "lua vim.lsp.buf.references()", desc = "References" }, - { "g.", "lua vim.lsp.buf.code_action()", desc = "Code action" }, - { "R", "lua vim.lsp.buf.rename()", desc = "Rename symbol" }, - { "F", "Format", desc = "Format buffer" }, - - { "gg", "LazyGit", desc = "Lazygit", group = "git" }, - { "gs", "Telescope git_status", desc = "Git status", group = "git" }, - { "gd", "Gitsigns diffthis vertical=true HEAD", desc = "File diff", group = "git" }, - { "Gd", ":Gitsigns diffthis vertical=true ", desc = "File diff provided ref", group = "git" }, - { "GD", ":DiffviewOpen ", desc = "Diff provided ref", group = "git" }, - { "gh", "DiffviewFileHistory %", desc = "File history", group = "git" }, - { "gH", "DiffviewFileHistory", desc = "Git history", group = "git" }, - { "gb", "Gitsigns toggle_current_line_blame", desc = "Git history", group = "git" }, - { - "gl", - 'lua require("gitlinker").get_buf_range_url("n", {action_callback = require("gitlinker.actions").copy_to_clipboard})', - desc = "Copy git url", - mode = "n", - silent = true, - }, - { - "gl", - 'lua require("gitlinker").get_buf_range_url("v", {action_callback = require("gitlinker.actions").copy_to_clipboard})', - desc = "Copy git url", - mode = "v", - -- TODO: make this actually silent - silent = true, - }, - - { "PP", "Lazy", desc = "Manage plugins", group = "plugin" }, - - { "CI", ":CodeCompanion", desc = "Code Companion inline", mode = { "n", "v" }, group = "codecompanion" }, - { "CC", ":CodeCompanionChat", desc = "Claude edit selection", mode = { "n", "v" }, group = "codecompanion" }, -}) +-- movement +vim.keymap.set("n", "", "h") +vim.keymap.set("n", "", "j") +vim.keymap.set("n", "", "k") +vim.keymap.set("n", "", "l") +vim.keymap.set("n", "", "5zl") +vim.keymap.set("n", "", "5zh") +vim.keymap.set("n", "H", ":bp") +vim.keymap.set("n", "L", ":bn") + +vim.keymap.set("n", "E", "Neotree toggle reveal position=current") + +-- buffers +vim.keymap.set("n", "BD", "bufdo bd") +vim.keymap.set("n", "n", "vnew") +-- Prevents the pane from being removed when closing a buffer +vim.keymap.set("n", "d", "bpspbnbd") +vim.keymap.set("n", "D", "bpspbnbd!") +vim.keymap.set("n", "v/", "vsp") +vim.keymap.set("n", "v?", "sp") + +-- tabs +vim.keymap.set("n", "", "tabnext") +vim.keymap.set("n", "tn", "tabnew") +vim.keymap.set("n", "td", "tabclose") + +-- comments +vim.keymap.set("n", "/", "CommentToggle") +vim.keymap.set("v", "/", ":'<,'>CommentToggle") + + +-- telescope +vim.keymap.set("n", + "f", + "Telescope find_files find_command=rg,--ignore,--hidden,--files,--iglob=!.git sort_mru=true" +) +vim.keymap.set("n", "b", "Telescope buffers") +vim.keymap.set("n", "sp", "Telescope live_grep") +vim.keymap.set("n", "sh", "Telescope help_tags") +vim.keymap.set("n", "sc", "Telescope commands") + +vim.keymap.set("n", "h", "noh") + +vim.keymap.set("n", "M", "messages") + +vim.keymap.set("n", "T", ":term ") + +vim.keymap.set("n", "m", function() + vim.diagnostic.setqflist({ open = true, focus = true }) +end) +vim.keymap.set("n", "cc", toggle_qf_list) +vim.keymap.set("n", "cn", "cnext") +vim.keymap.set("n", "cp", "cprev") + +-- write/quit +vim.keymap.set("n", "w", "w") +vim.keymap.set("n", "X", "x") +vim.keymap.set("n", "q", "q") +vim.keymap.set("n", "Q", "qa") + +-- lsp +vim.keymap.set("n", "[d", "lua vim.diagnostic.goto_prev()") +vim.keymap.set("n", "]d", "lua vim.diagnostic.goto_next()") +vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()") +vim.keymap.set("n", "gs", "Telescope lsp_document_symbols") +vim.keymap.set("n", "gS", "Telescope lsp_dynamic_workspace_symbols") +vim.keymap.set("n", "gD", "lua vim.lsp.buf.declaration()") +vim.keymap.set("n", "gd", "lua vim.lsp.buf.definition()") +vim.keymap.set("n", "gi", "lua vim.lsp.buf.implementation()") +vim.keymap.set("n", "gr", "lua vim.lsp.buf.references()") +vim.keymap.set("n", "g.", "lua vim.lsp.buf.code_action()") +vim.keymap.set("n", "R", "lua vim.lsp.buf.rename()") +vim.keymap.set("n", "F", "Format") + +-- trouble +vim.keymap.set("n", "xx", "Trouble diagnostics toggle", { desc = "Diagnostics (Trouble)" }) +vim.keymap.set("n", "xX", "Trouble diagnostics toggle filter.buf=0", + { desc = "Buffer Diagnostics (Trouble)" }) +vim.keymap.set("n", "cs", "Trouble symbols toggle focus=false win.position=bottom", + { desc = "Symbols (Trouble)" }) +vim.keymap.set("n", "cl", "Trouble lsp toggle focus=false", + { desc = "LSP Definitions / references / ... (Trouble)" }) +vim.keymap.set("n", "xL", "Trouble loclist toggle", { desc = "Location List (Trouble)" }) +vim.keymap.set("n", "xQ", "Trouble qflist toggle", { desc = "Quickfix List (Trouble)" }) + +-- git +vim.keymap.set("n", "[g", "Gitsigns prev_hunk") +vim.keymap.set("n", "]g", "Gitsigns next_hunk") +vim.keymap.set("n", "gg", "LazyGit") +vim.keymap.set("n", "gs", "Telescope git_status") +vim.keymap.set("n", "gd", "Gitsigns diffthis vertical=true HEAD") +vim.keymap.set("n", "Gd", ":Gitsigns diffthis vertical=true ") +vim.keymap.set("n", "GD", ":DiffviewOpen ") +vim.keymap.set("n", "gh", "DiffviewFileHistory %") +vim.keymap.set("n", "gH", "DiffviewFileHistory") +vim.keymap.set("n", "gb", "Gitsigns toggle_current_line_blame") + +vim.keymap.set("v", "gl", function() + require("gitlinker").get_buf_range_url("n", { + action_callback = require("gitlinker.actions").copy_to_clipboard + }) +end, { silent = true }) + +vim.keymap.set("v", "gl", function() + require("gitlinker").get_buf_range_url("v", { + action_callback = require("gitlinker.actions").copy_to_clipboard + }) +end, { silent = true }) + +vim.keymap.set("n", "y", function() + local filepath = vim.fn.expand('%:.') + local line = vim.fn.line('.') + local ref = filepath .. ':' .. line + vim.fn.system('pbcopy', ref) + vim.notify('Copied: ' .. ref, vim.log.levels.INFO) +end, { desc = "Copy filepath:line to clipboard" }) + +vim.keymap.set("n", "PP", "Lazy") + +vim.keymap.set("n", "LC", "ConfigLocalEdit") +vim.keymap.set("n", "N", "e NOTES.sethetter.md") diff --git a/nvim/lua/plugins/config.lua b/nvim/lua/plugins/config.lua index 7007baa..271236d 100644 --- a/nvim/lua/plugins/config.lua +++ b/nvim/lua/plugins/config.lua @@ -9,9 +9,16 @@ return { hashfile = vim.fn.stdpath("data") .. "/config-local", autocommands_create = true, -- Create autocommands (VimEnter, DirectoryChanged) - commands_create = true, -- Create commands (ConfigLocalSource, ConfigLocalEdit, ConfigLocalTrust, ConfigLocalIgnore) - silent = false, -- Disable plugin messages (Config loaded/ignored) - lookup_parents = false, -- Lookup config files in parent directories + commands_create = true, -- Create commands (ConfigLocalSource, ConfigLocalEdit, ConfigLocalTrust, ConfigLocalIgnore) + silent = false, -- Disable plugin messages (Config loaded/ignored) + lookup_parents = false, -- Lookup config files in parent directories }) end, + keys = { + { + "LC", + "ConfigLocalEdit", + desc = "Edit local config", + }, + }, } diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index d85d4d9..8719408 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -158,6 +158,18 @@ return { }) end, }, + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = {}, + }, + { + "folke/trouble.nvim", + opts = { + icons = {}, + }, + cmd = "Trouble", + }, { "antosha417/nvim-lsp-file-operations", dependencies = { diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index e58ae1b..838bbf2 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua @@ -32,18 +32,6 @@ return { }, }, }, - { - "stevearc/aerial.nvim", - opts = { - -- default starts with treesitter, but I like lsp - backends = { "lsp", "markdown", "asciidoc", "man" }, - filter_kind = false, - layout = { - max_width = { 40, 0.2 }, - min_width = 30, - }, - }, - }, { "nvim-telescope/telescope.nvim", tag = "0.1.8", -- 2.51.2