From 42dc2d822cd755abdb0fd8a77b67b2912f78fb4b Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Tue, 26 Dec 2023 16:54:54 -0600 Subject: [PATCH] feat(nvim): add bindings for visual mode macro invocations NOTE: This is implementing https://github.com/neovim/neovim/pull/26495 early. Once that is merged this is no longer needed. --- dots/.config/nvim/lua/core/mappings.lua | 6 ++++++ dots/.config/nvim/lua/plugins/configs/various-textobjs.lua | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dots/.config/nvim/lua/core/mappings.lua b/dots/.config/nvim/lua/core/mappings.lua index 882d5fd8..ba783cf4 100755 --- a/dots/.config/nvim/lua/core/mappings.lua +++ b/dots/.config/nvim/lua/core/mappings.lua @@ -105,6 +105,12 @@ M.setup = function() -- Binding to allow shift tab dedent vim.keymap.set("i", "", "", { silent = true, desc = "Insert: Dedent" }) + + -- Allow macros to be invoked over a visual range via a keybind in visual mode + vim.keymap.set("x", "@", "':normal! @'.getcharstr().''", + { silent = true, expr = true, desc = "Call Macro Against Visual Selection" }) + vim.keymap.set("x", "Q", ':normal! @=reg_recorded()', + { silent = true, desc = "Call Last Macro Against Visual Selection" }) end return M diff --git a/dots/.config/nvim/lua/plugins/configs/various-textobjs.lua b/dots/.config/nvim/lua/plugins/configs/various-textobjs.lua index 307a6ef5..de0644e6 100644 --- a/dots/.config/nvim/lua/plugins/configs/various-textobjs.lua +++ b/dots/.config/nvim/lua/plugins/configs/various-textobjs.lua @@ -3,7 +3,7 @@ return { "chrisgrieser/nvim-various-textobjs", opts = { useDefaultKeymaps = true, - disabledKeymaps = { "r", "R" }, + disabledKeymaps = { "r", "R", "Q" }, }, }, }