feature: allow cmp confirm options to be configurable (#1523)

This commit is contained in:
Chase Colman 2021-09-21 14:54:47 +08:00 committed by GitHub
parent 279d537e9c
commit fbfd8c1fc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,6 +30,10 @@ M.config = function()
return
end
lvim.builtin.cmp = {
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
formatting = {
format = function(entry, vim_item)
local icons = require("lsp.kind").icons
@ -107,10 +111,15 @@ M.config = function()
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
["<CR>"] = cmp.mapping(function(fallback)
if not require("cmp").confirm(lvim.builtin.cmp.confirm_opts) then
if luasnip.jumpable() then
vim.fn.feedkeys(T "<Plug>luasnip-jump-next", "")
else
fallback()
end
end
end),
},
}
end