diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 45c89c4a..c618578b 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -4,12 +4,6 @@ -- use `vim.keymap.set` instead local map = LazyVim.safe_keymap_set --- Clear search and stop snippet on escape -Snacks.util.on_key("", function() - vim.cmd("noh") - LazyVim.cmp.actions.snippet_stop() -end) - -- better up/down map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true }) map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true }) @@ -51,6 +45,13 @@ map("n", "bo", function() end, { desc = "Delete Other Buffers" }) map("n", "bD", ":bd", { desc = "Delete Buffer and Window" }) +-- Clear search and stop snippet on escape +map({ "i", "n", "s" }, "", function() + vim.cmd("noh") + LazyVim.cmp.actions.snippet_stop() + return "" +end, { expr = true, desc = "Escape and Clear hlsearch" }) + -- Clear search, diff update and redraw -- taken from runtime/lua/_editor.lua map(