-
I want to insert undo breakpoints when performing a completion so it's easy to go return when e.g. selecting the wrong snippet. My current solution looks like this, utilzing an autocommand to combine vim mapping and calling lua func vim.api.nvim_create_user_command("CmpComplete", function()
if cmp.visible() then
cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})()
end
end, {})
vim.keymap.set("i", "<c-i>", "<c-g>u<cmd>CmpComplete<CR>", {}) Any advice on a more ellegant way on achiveing this? E.g. though the mapping option? I couldn't find a way to create breakpoints from lua myself. |
Beta Was this translation helpful? Give feedback.
Answered by
fitrh
Jan 19, 2024
Replies: 1 comment 1 reply
-
I think in your cmp mapping you can do something like this mapping = {
['<C-i>'] = cmp.mapping({
i = function(fallback)
if cmp.visible() then
local CTRLg_u = vim.api.nvim_replace_termcodes('<C-g>u', true, true, true)
vim.api.nvim_feedkeys(CTRLg_u, 'n', true)
return cmp.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
end
fallback()
end,
}),
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
GNRSN
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think in your cmp mapping you can do something like this