浏览代码

nixpkgs/neovim: configure cmp

Thomas Dy 1 年之前
父节点
当前提交
9934cb6f1a
共有 1 个文件被更改,包括 19 次插入1 次删除
  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