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

Commit aa5cc61

Browse files
authored
Merge pull request #330 from nvim-lua/sort_text
feat: makes the default sorting corresponding to sortText provided by…
2 parents dc4cf56 + b5f222b commit aa5cc61

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lua/completion/source/lsp.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ M.getCompletionItems = function(_, _)
1313
return M.items
1414
end
1515

16+
local function sort_completion_items(items)
17+
table.sort(items, function(a, b)
18+
return (a.sortText or a.label) < (b.sortText or b.label)
19+
end)
20+
end
21+
1622
local function get_completion_word(item, prefix, suffix)
1723
if item.textEdit ~= nil and item.textEdit ~= vim.NIL
1824
and item.textEdit.newText ~= nil and (item.insertTextFormat ~= 2 or vim.fn.exists('g:loaded_vsnip_integ')) then
@@ -74,7 +80,7 @@ local function text_document_completion_list_to_complete_items(result, params)
7480

7581
local customize_label = opt.get_option('customize_lsp_label')
7682
-- items = remove_unmatch_completion_items(items, prefix)
77-
-- sort_completion_items(items)
83+
sort_completion_items(items)
7884

7985
local matches = {}
8086

0 commit comments

Comments
 (0)