From: Daniel Viberg Date: Tue, 2 Jan 2024 20:24:15 +0000 (+0100) Subject: Added option for removing duplicate completion items X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=66af9f0327cdbf358f3868e49c0e64ec61b4c892;p=vim-lsp.git Added option for removing duplicate completion items --- diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 4ab65dd..a145829 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -188,6 +188,7 @@ export def CompletionReply(lspserver: dict, cItems: any) endif var completeItems: list> = [] + var itemsUsed: list = [] for item in items var d: dict = {} @@ -295,6 +296,20 @@ export def CompletionReply(lspserver: dict, cItems: any) d.score = item->get('label', '') endif + # Dont include duplicate items + if lspOpts.filterCompletionDuplicates + var key = d->get('word', '') .. + d->get('info', '') .. + d->get('kind', '') .. + d->get('score', '') .. + d->get('abbr', '') .. + d->get('dup', '') + if index(itemsUsed, key) != -1 + continue + endif + add(itemsUsed, key) + endif + d.user_data = item completeItems->add(d) endfor diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index dbe23dc..18e23dd 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -135,7 +135,10 @@ export var lspOptions: dict = { customCompletionKinds: false, # A dictionary with all completion kinds that you want to customize - completionKinds: {} + completionKinds: {}, + + # Filter duplicate completion items + filterCompletionDuplicates: false, } # set the LSP plugin options from the user provided option values