diff --git a/dots/.config/nvim/lua/plugins/configs/cmp.lua b/dots/.config/nvim/lua/plugins/configs/cmp.lua index 7bbc53d8..7e7b4896 100644 --- a/dots/.config/nvim/lua/plugins/configs/cmp.lua +++ b/dots/.config/nvim/lua/plugins/configs/cmp.lua @@ -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, }, }, })