Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

Commit c5ecfe9

Browse files
committed
feat: sorting with length desc(#168)
1 parent f2293f8 commit c5ecfe9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lua/completion/util.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@ end
1717
------------------------
1818

1919
function M.sort_completion_items(items)
20+
print(opt.get_option("sorting"))
2021
table.sort(items, function(a, b)
2122
if a.priority ~= b.priority and a.priority ~= nil and b.priority ~= nil then
2223
return a.priority > b.priority
2324
elseif a.score ~= b.score and a.score ~= nil and b.score ~= nil then
2425
return a.score < b.score
25-
elseif vim.g.completion_sorting == 'alphabet' then
26+
elseif opt.get_option("sorting") == 'alphabet' then
2627
return a.word < b.word
28+
elseif opt.get_option("sorting") == 'length_desc' then
29+
return string.len(a.word) > string.len(b.word)
2730
else
2831
return string.len(a.word) < string.len(b.word)
2932
end

0 commit comments

Comments
 (0)