diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 99e65c34..a4c8f353 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -4,6 +4,14 @@ -- 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") + if vim.snippet then + vim.snippet.stop() + end +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 }) @@ -45,9 +53,6 @@ map("n", "bo", function() end, { desc = "Delete Other Buffers" }) map("n", "bD", ":bd", { desc = "Delete Buffer and Window" }) --- Clear search with -map({ "i", "n" }, "", "noh", { desc = "Escape and Clear hlsearch" }) - -- Clear search, diff update and redraw -- taken from runtime/lua/_editor.lua map(