refactor(nvim): improve cmp sorting

This commit is contained in:
Price Hiller 2024-01-16 16:41:46 -06:00
parent 65f1d3c253
commit c078cf6142
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8

View File

@ -341,15 +341,24 @@ return {
sorting = {
priority_weight = 2,
comparators = {
require("cmp_fuzzy_buffer.compare"),
compare.score,
compare.offset,
compare.locality,
compare.recently_used,
compare.score,
require("cmp_fuzzy_buffer.compare"),
compare.offset,
compare.exact,
compare.kind,
compare.sort_text,
compare.length,
compare.order,
-- Copied from cmp-under-comparator
function(entry1, entry2)
local _, entry1_under = entry1.completion_item.label:find "^_+"
local _, entry2_under = entry2.completion_item.label:find "^_+"
entry1_under = entry1_under or 0
entry2_under = entry2_under or 0
if entry1_under > entry2_under then
return false
elseif entry1_under < entry2_under then
return true
end
end,
},
},
})