feat(keymaps): stop native snippets on escape. Closes #5083

This commit is contained in:
Folke Lemaitre 2024-12-15 08:27:43 +01:00
parent 195a6e6114
commit 15c81fdbb8
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -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("<esc>", 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" }, "<Down>", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true })
@ -45,9 +53,6 @@ map("n", "<leader>bo", function()
end, { desc = "Delete Other Buffers" })
map("n", "<leader>bD", "<cmd>:bd<cr>", { desc = "Delete Buffer and Window" })
-- Clear search with <esc>
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and Clear hlsearch" })
-- Clear search, diff update and redraw
-- taken from runtime/lua/_editor.lua
map(