Browse Source

nixpkgs/neovim: configure cmp

Thomas Dy 7 months ago
parent
commit
9934cb6f1a
1 changed files with 19 additions and 1 deletions
  1. 19 1
      .config/nixpkgs/neovim/plugins.lua

+ 19 - 1
.config/nixpkgs/neovim/plugins.lua

@@ -160,6 +160,7 @@ require('treesj').setup({
 
 -- completion
 local cmp = require('cmp')
+local cmp_types = require('cmp.types')
 cmp.setup({
   snippet = {
     expand = function(args)
@@ -174,12 +175,29 @@ cmp.setup({
     ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
   }),
   sources = cmp.config.sources({
-    { name = "nvim_lsp" },
+    {
+      name = "nvim_lsp",
+      entry_filter = function(entry, ctx)
+        -- don't autocomplete keywords
+        return cmp_types.lsp.CompletionItemKind[entry:get_kind()] ~= 'Keyword'
+      end
+    },
     { name = "vsnip" },
   }),
   completion = {
     autocomplete = false,
   },
+  matching = {
+    -- disable non-prefix matching
+    disallow_partial_matching = true,
+    disallow_prefix_unmatching = true,
+  },
+  sorting = {
+    comparators = {
+      -- since we only have prefix matches, just sort the results
+      cmp.config.compare.sort_text,
+    },
+  },
 })
 
 -- typescript-vim compiler options