فهرست منبع

nixpkgs/neovim: fix cmp sorting

Thomas Dy 4 ماه پیش
والد
کامیت
c12fa7a1d1
1فایلهای تغییر یافته به همراه11 افزوده شده و 1 حذف شده
  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,
     },
   },
 })