summary refs log tree commit diff
path: root/.vim/lua/plugins.lua
diff options
context:
space:
mode:
Diffstat (limited to '.vim/lua/plugins.lua')
-rw-r--r--.vim/lua/plugins.lua41
1 files changed, 22 insertions, 19 deletions
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua
index 3e61292..711d4cf 100644
--- a/.vim/lua/plugins.lua
+++ b/.vim/lua/plugins.lua
@@ -495,9 +495,16 @@ require('packer').startup({function()
       local cmp = require('cmp')
       local luasnip = require('luasnip')
       cmp.setup {
-        completion = {
-          -- autocomplete = { cmp.TriggerEvent.TextChanged }
-        },
+        -- disable completion in comments
+        enabled = function()
+          local ctx = require('cmp.config.context')
+          if vim.api.nvim_get_mode().mode == 'c' then
+            return true
+          else
+            return ctx.in_treesitter_capture('comment')
+              and not ctx.in_syntax_group('Comment')
+          end
+        end,
         preselect = cmp.PreselectMode.Item,
         window = {
           documentation = {
@@ -507,7 +514,7 @@ require('packer').startup({function()
         mapping = { -- {{{2
           ['<cr>'] = cmp.mapping(function(fallback)
               if cmp.visible() then
-                cmp.confirm({ select = true })
+                cmp.mapping.confirm({ select = true })
               elseif luasnip.expandable() then
                 luasnip.expand()
               else
@@ -515,10 +522,6 @@ require('packer').startup({function()
               end
             end),
           ['<c-space>'] = cmp.mapping.complete(),
-          ['<c-e>'] = cmp.mapping({
-              i = cmp.mapping.abort(),
-              c = cmp.mapping.close(),
-            }),
           ['<c-n>'] = cmp.mapping(function(fallback)
               if cmp.visible() then
                 cmp.select_next_item()
@@ -540,7 +543,7 @@ require('packer').startup({function()
           ['<tab>'] = cmp.mapping({
               i = function(fallback)
                 if cmp.visible() then
-                  cmp.confirm({ select = true })
+                  cmp.mapping.confirm({ select = true })
                 elseif luasnip.expand_or_locally_jumpable() then
                   luasnip.expand_or_jump()
                 else
@@ -644,22 +647,22 @@ require('packer').startup({function()
           end,
         },
       }
-      cmp.setup.cmdline('/', {
-        sources = cmp.config.sources({
-          { name = 'nvim_lsp_document_symbol' }
-        }, {
+      cmp.setup.cmdline({'/', '?', '@'}, {
+        mapping = cmp.mapping.preset.cmdline(),
+        sources = {
+          { name = 'nvim_lsp_document_symbol' },
           { name = 'buffer' }
-        }),
+        },
         formatting = {
           fields = {'abbr', 'menu'},
         },
       })
       cmp.setup.cmdline(':', {
-        sources = cmp.config.sources({
-          { name = 'path' }
-        }, {
+        mapping = cmp.mapping.preset.cmdline(),
+        sources = {
+          { name = 'path' },
           { name = 'cmdline' }
-        }),
+        },
         formatting = {
           fields = {'abbr', 'menu'},
         },
@@ -667,7 +670,7 @@ require('packer').startup({function()
 
       -- insert `(` after selecting function/method items
       cmp.event:on('confirm_done', require('nvim-autopairs.completion.cmp').on_confirm_done {
-        map_char = { tex = '' }
+        map_char = {tex = ''}
       })
     end} -- }}}