Parcourir la source

nixpkgs/neovim: fix cmp sorting

Thomas Dy il y a 4 mois
Parent
commit
c12fa7a1d1
1 fichiers modifiés avec 11 ajouts et 1 suppressions
  1. 11 1
      .config/nixpkgs/neovim/plugins.lua

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

@@ -252,6 +252,16 @@ require('treesj').setup({
 -- completion
 local cmp = require('cmp')
 local cmp_types = require('cmp.types')
+
+function sort_label(entry1, entry2)
+  local diff = vim.stricmp(entry1.completion_item.label, entry2.completion_item.label)
+  if diff < 0 then
+    return true
+  elseif diff > 0 then
+    return false
+  end
+end
+
 cmp.setup({
   snippet = {
     expand = function(args)
@@ -287,7 +297,7 @@ cmp.setup({
   sorting = {
     comparators = {
       -- since we only have prefix matches, just sort the results
-      cmp.config.compare.sort_text,
+      sort_label,
     },
   },
 })