refactor(nvim): improve cmp sorting
This commit is contained in:
parent
65f1d3c253
commit
c078cf6142
@ -341,15 +341,24 @@ return {
|
|||||||
sorting = {
|
sorting = {
|
||||||
priority_weight = 2,
|
priority_weight = 2,
|
||||||
comparators = {
|
comparators = {
|
||||||
require("cmp_fuzzy_buffer.compare"),
|
compare.locality,
|
||||||
compare.score,
|
|
||||||
compare.offset,
|
|
||||||
compare.recently_used,
|
compare.recently_used,
|
||||||
|
compare.score,
|
||||||
|
require("cmp_fuzzy_buffer.compare"),
|
||||||
|
compare.offset,
|
||||||
compare.exact,
|
compare.exact,
|
||||||
compare.kind,
|
-- Copied from cmp-under-comparator
|
||||||
compare.sort_text,
|
function(entry1, entry2)
|
||||||
compare.length,
|
local _, entry1_under = entry1.completion_item.label:find "^_+"
|
||||||
compare.order,
|
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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user