feat(cmp): create undo point right before confirming a completion

This commit is contained in:
Folke Lemaitre
2024-05-18 23:28:35 +02:00
parent 96aa4b8877
commit 673975ebbe
2 changed files with 17 additions and 1 deletions

View File

@ -36,7 +36,15 @@ return {
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<CR>"] = function(fallback)
if cmp.visible() then
LazyVim.create_undo()
if cmp.confirm({ select = true }) then
return
end
end
return fallback()
end,
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,