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

Commit 6c63530

Browse files
committed
feat: add option to disable or use different sorting
1 parent da8cc77 commit 6c63530

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

lua/completion/util.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ local function remove_unmatch_completion_items(items, prefix)
3131
end
3232

3333
function M.sort_completion_items(items)
34+
if vim.g.completion_sorting == 'none' then
35+
return
36+
end
3437
table.sort(items, function(a, b)
3538
if a.priority ~= b.priority and a.priority ~= nil and b.priority ~= nil then
3639
return a.priority > b.priority
37-
elseif vim.g.completion_sorted_alphabetically then
40+
elseif vim.g.completion_sorting == 'alphabet' then
3841
return a.word < b.word
3942
elseif a.score ~= b.score and a.score ~= nil and b.score ~= nil then
4043
return a.score < b.score
@@ -54,7 +57,6 @@ function M.text_document_completion_list_to_complete_items(result, prefix)
5457
local buf_customize_label = api.nvim_call_function(
5558
'completion#get_buffer_variable', {'completion_buf_customize_lsp_label'})
5659
if buf_customize_label == nil then buf_customize_label = {} end
57-
5860
items = remove_unmatch_completion_items(items, prefix)
5961
-- sort_completion_items(items)
6062

plugin/completion.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ if !exists('g:completion_timer_cycle')
6565
let g:completion_timer_cycle = 80
6666
endif
6767

68+
if ! exists('g:completion_sorting')
69+
let g:completion_sorting = 'length'
70+
endif
71+
6872
if ! exists('g:completion_sorted_alphabetically')
6973
let g:completion_sorted_alphabetically = v:false
7074
endif

0 commit comments

Comments
 (0)