feat(keymaps): unlink luasnip on esc
This commit is contained in:
@ -7,9 +7,7 @@ local map = LazyVim.safe_keymap_set
|
|||||||
-- Clear search and stop snippet on escape
|
-- Clear search and stop snippet on escape
|
||||||
Snacks.util.on_key("<esc>", function()
|
Snacks.util.on_key("<esc>", function()
|
||||||
vim.cmd("noh")
|
vim.cmd("noh")
|
||||||
if vim.snippet then
|
LazyVim.cmp.actions.snippet_stop()
|
||||||
vim.snippet.stop()
|
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- better up/down
|
-- better up/down
|
||||||
|
@ -34,6 +34,12 @@ return {
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
LazyVim.cmp.actions.snippet_stop = function()
|
||||||
|
if require("luasnip").expand_or_jumpable() then -- or just jumpable(1) is fine?
|
||||||
|
require("luasnip").unlink_current()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@ M.actions = {
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
snippet_stop = function()
|
||||||
|
if vim.snippet then
|
||||||
|
vim.snippet.stop()
|
||||||
|
end
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
---@param actions string[]
|
---@param actions string[]
|
||||||
|
Reference in New Issue
Block a user