From 7a3aa50d7fb712eb17a68b8c6626c65be80e4d48 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 17 Apr 2026 10:53:54 +0100 Subject: refactor: audit and fix neovim keybinds - fix visual p register clobbering: use "_dP black-hole pattern - remove ; -> : mapping: restore native repeat-find motion - remove / -> ^/$ emacs mappings: anti-vim-philosophy - map dial.nvim to //g/g (standard increment keys) - remove redundant oq diagnostic loclist (covered by tl) - collapse {,v,x,t}D type-def onto g{v,x,t}t pattern (0.12 grt) - move oc/ic calls to co/ci (Code group) - add gvr/gxr/gtr for references in splits - remove empty s and d which-key group declarations --- home/.config/nvim/lua/config/keymaps.lua | 22 ++-------------------- home/.config/nvim/lua/plugins/editing.lua | 16 +++++++++++----- home/.config/nvim/lua/plugins/init.lua | 2 -- home/.config/nvim/lua/plugins/lsp.lua | 26 +++++++++++++++++--------- 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/home/.config/nvim/lua/config/keymaps.lua b/home/.config/nvim/lua/config/keymaps.lua index 349fc96..366a37e 100644 --- a/home/.config/nvim/lua/config/keymaps.lua +++ b/home/.config/nvim/lua/config/keymaps.lua @@ -28,26 +28,14 @@ end ncmd("", "nohlsearch") --- make an accidental ; press also enter command mode -nmap(";", ":") - -- highlight last inserted text nmap("gV", "`[v`]") nmap("", "") nmap("", "") --- go to first non-blank character of current line -nvmap("", "^") -nvmap("", "$") - --- This extends p in visual mode (note the noremap), so that if you paste from --- the unnamed (ie. default) register, that register content is not replaced by --- the visual selection you just pasted over–which is the default behavior. --- This enables the user to yank some text and paste it over several places in --- a row, without using a named register --- map.v('p', "p:if v:register == '"'let @@=@0endif") -vmap("p", 'p:let @+=@0:let @"=@0') +-- paste over selection without clobbering registers +vmap("p", '"_dP') -- Find and Replace binds ncmdi("s", "%s/") @@ -89,12 +77,6 @@ nmap("]e", function() }) end) -nmap( - "oq", - vim.diagnostic.setloclist, - "[O]pen diagnostic [Q]uickfix list" -) - nmap("yp", function() vim.fn.setreg("+", vim.fn.expand("%")) end, "[Y]ank [P]ath") diff --git a/home/.config/nvim/lua/plugins/editing.lua b/home/.config/nvim/lua/plugins/editing.lua index bcbfc6f..5175516 100644 --- a/home/.config/nvim/lua/plugins/editing.lua +++ b/home/.config/nvim/lua/plugins/editing.lua @@ -6,19 +6,25 @@ require("various-textobjs").setup({ }, }) --- dial.nvim keymaps -vim.keymap.set("n", "]i", function() +-- dial.nvim: enhanced increment/decrement on standard vim keys +vim.keymap.set("n", "", function() return require("dial.map").inc_normal() end, { expr = true, desc = "Increment" }) -vim.keymap.set("n", "[i", function() +vim.keymap.set("n", "", function() return require("dial.map").dec_normal() end, { expr = true, desc = "Decrement" }) -vim.keymap.set("v", "]i", function() +vim.keymap.set("v", "", function() return require("dial.map").inc_visual() end, { expr = true, desc = "Increment" }) -vim.keymap.set("v", "[i", function() +vim.keymap.set("v", "", function() return require("dial.map").dec_visual() end, { expr = true, desc = "Decrement" }) +vim.keymap.set("v", "g", function() + return require("dial.map").inc_gvisual() +end, { expr = true, desc = "Increment (sequential)" }) +vim.keymap.set("v", "g", function() + return require("dial.map").dec_gvisual() +end, { expr = true, desc = "Decrement (sequential)" }) -- refactoring.nvim require("refactoring").setup({}) diff --git a/home/.config/nvim/lua/plugins/init.lua b/home/.config/nvim/lua/plugins/init.lua index a0a6d49..b106b6e 100644 --- a/home/.config/nvim/lua/plugins/init.lua +++ b/home/.config/nvim/lua/plugins/init.lua @@ -12,12 +12,10 @@ require("which-key").setup({ { "]", group = "Navigate to next" }, { "[", group = "Navigate to previous" }, { "c", group = "[C]ode", mode = { "n", "x" } }, - { "d", group = "[D]ocument" }, { "g", group = "[G]it" }, { "h", group = "Git [H]unk", mode = { "n", "v" } }, { "o", group = "[O]verseer" }, { "r", group = "[R]efactor" }, - { "s", group = "[S]earch" }, { "w", group = "[W]orkspace" }, { "t", group = "[T]oggle" }, }, diff --git a/home/.config/nvim/lua/plugins/lsp.lua b/home/.config/nvim/lua/plugins/lsp.lua index 2e334c8..ddd5bea 100644 --- a/home/.config/nvim/lua/plugins/lsp.lua +++ b/home/.config/nvim/lua/plugins/lsp.lua @@ -88,16 +88,15 @@ vim.api.nvim_create_autocmd("LspAttach", { nmap("gtd", function() fzf.lsp_definitions({ jump1_action = fzf.actions.file_tabedit }) end, "[G]oto in a [T]ab to [D]efinition") - nmap("D", fzf.lsp_typedefs, "Type [D]efinition") - nmap("vD", function() + nmap("gvt", function() fzf.lsp_typedefs({ jump1_action = fzf.actions.file_vsplit }) - end, "Open in a [V]ertical split Type [D]efinition") - nmap("xD", function() + end, "[G]oto in a [V]ertical split to [T]ype definition") + nmap("gxt", function() fzf.lsp_typedefs({ jump1_action = fzf.actions.file_split }) - end, "Open in a [X]horizontal split Type [D]efinition") - nmap("tD", function() + end, "[G]oto in a [X]horizontal split to [T]ype definition") + nmap("gtt", function() fzf.lsp_typedefs({ jump1_action = fzf.actions.file_tabedit }) - end, "Open in a [T]ab Type [D]efinition") + end, "[G]oto in a [T]ab to [T]ype definition") nmap("gri", fzf.lsp_implementations, "[G]oto [I]mplementation") nmap("grvi", function() fzf.lsp_implementations({ jump1_action = fzf.actions.file_vsplit }) @@ -109,8 +108,17 @@ vim.api.nvim_create_autocmd("LspAttach", { fzf.lsp_implementations({ jump1_action = fzf.actions.file_tabedit }) end, "[G]oto in a [T]ab to [I]mplementation") nmap("grr", fzf.lsp_references, "[G]oto [R]eferences") - nmap("ic", fzf.lsp_incoming_calls, "[I]ncoming [C]alls") - nmap("oc", fzf.lsp_outgoing_calls, "[O]utgoing [C]alls") + nmap("gvr", function() + fzf.lsp_references({ jump1_action = fzf.actions.file_vsplit }) + end, "[G]oto in a [V]ertical split to [R]eferences") + nmap("gxr", function() + fzf.lsp_references({ jump1_action = fzf.actions.file_split }) + end, "[G]oto in a [X]horizontal split to [R]eferences") + nmap("gtr", function() + fzf.lsp_references({ jump1_action = fzf.actions.file_tabedit }) + end, "[G]oto in a [T]ab to [R]eferences") + nmap("ci", fzf.lsp_incoming_calls, "[C]ode [I]ncoming calls") + nmap("co", fzf.lsp_outgoing_calls, "[C]ode [O]utgoing calls") nmap("gO", fzf.lsp_document_symbols, "d[O]ocument symbols") nmap( "ws", -- cgit v1.2.3-70-g09d2