Quellcode durchsuchen

Adding popup cmp autocomplete hotkey changes. ESC closes and leaves
Insert mode now, and Tab does not select, but inserts a tab.

Don Duvall vor 11 Monaten
Ursprung
Commit
6e416563ce
2 geänderte Dateien mit 13 neuen und 3 gelöschten Zeilen
  1. 1 0
      lua/config/lazy.lua
  2. 12 3
      lua/plugins/nvim-cmp.lua

+ 1 - 0
lua/config/lazy.lua

@@ -13,6 +13,7 @@ require("lazy").setup({
     -- import any extras modules here
     -- { import = "lazyvim.plugins.extras.lang.typescript" },
     { import = "lazyvim.plugins.extras.lang.json" },
+    { import = "lazyvim.plugins.extras.lang.clangd" },
     -- { import = "lazyvim.plugins.extras.ui.mini-animate" },
     -- import/override with your plugins
     { import = "plugins" },

+ 12 - 3
lua/plugins/nvim-cmp.lua

@@ -36,7 +36,7 @@ return {
 
             opts.mapping = vim.tbl_extend("force", opts.mapping, {
                 -- Define the down arrow to select the next item in the completion menu
-                ["<Down>"] = cmp.mapping(function(fallback) 
+                ["<Down>"] = cmp.mapping(function(fallback)
                     if cmp.visible() then
                         cmp.select_next_item()
                     elseif luasnip.expand_or_jumpable() then
@@ -77,12 +77,21 @@ return {
                 --         fallback()
                 --     end
                 -- end, { "i", "s" }),
-                ["<Tab>"] = cmp.mapping.confirm({
+                ["<CR>"] = cmp.mapping.confirm({
                     behavior = cmp.ConfirmBehavior.Replace,
                     select = true,
                 }),
                 ["<C-Space>"] = cmp.mapping.complete(),
-                ["<Esc>"] = cmp.mapping.close(),
+                ["<Esc>"] = cmp.mapping({
+                    i = cmp.mapping.abort(),
+                    c = function()
+                        if cmp.visible() then
+                            cmp.close()
+                        else
+                            vim.api.nvim_feedkays(vim.api.nvim_replace_termcodes("<C-c>", true, true, true), "n", true)
+                        end
+                    end,
+                }),
                 --["<C-t>"] = { 
                 --    "copilot#Accept('\\<CR>')", 
                 --    desc = "copilot expand",