diff options
author | Chase Colman <[email protected]> | 2021-09-21 14:54:47 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-21 08:54:47 +0200 |
commit | fbfd8c1fc3d0df1e2169df64c2264de7e23a9105 (patch) | |
tree | cdc68773a6035f1eda89e396918ac92cb8ffe44e /lua/core/cmp.lua | |
parent | 279d537e9c96759ec0372496b786a2d28247d093 (diff) |
feature: allow cmp confirm options to be configurable (#1523)
Diffstat (limited to 'lua/core/cmp.lua')
-rw-r--r-- | lua/core/cmp.lua | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lua/core/cmp.lua b/lua/core/cmp.lua index 928b7e3a..2bc724fb 100644 --- a/lua/core/cmp.lua +++ b/lua/core/cmp.lua @@ -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 |