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