Selaa lähdekoodia

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

Chase Colman 3 vuotta sitten
vanhempi
commit
fbfd8c1fc3
1 muutettua tiedostoa jossa 13 lisäystä ja 4 poistoa
  1. 13 4
      lua/core/cmp.lua

+ 13 - 4
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