From d57ed6122bb143a4c1894c11b9309ed1e418f2d8 Mon Sep 17 00:00:00 2001 From: berggeist <24396556+berggeist@users.noreply.github.com> Date: Tue, 21 Jan 2025 16:31:57 +0100 Subject: [PATCH] Add option to condense completion menu items. (#582) --- autoload/lsp/completion.vim | 20 ++++++++++++++++++++ autoload/lsp/options.vim | 3 +++ doc/lsp.txt | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 8ce5899..acc6174 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -310,6 +310,26 @@ export def CompletionReply(lspserver: dict, cItems: any) endif d.user_data = item + + # Condense completion menu items to single words (plus kind) + # Move all additional details to the info popup + # Caveat: LazyDoc will override moved details! + if lspOpts.condensedCompletionMenu + const SEP = (s) => empty(s) ? "" : "\n- - -\n" + var infoText = '' + if d->has_key('abbr') && len(d.abbr) > len(d.word) + infoText ..= SEP(infoText) .. ' ' .. d.abbr + d.abbr = d.word + endif + if d->has_key('menu') && !empty(d.menu) + infoText ..= SEP(infoText) .. ' ' .. d.menu + d.menu = '' + endif + if !lspserver.completionLazyDoc && !empty(infoText) + d.info = infoText .. (d->has_key('info') ? SEP(infoText) .. d.info : '') + endif + endif + completeItems->add(d) endfor diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index 50697a3..9555e32 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -143,6 +143,9 @@ export var lspOptions: dict = { # Filter duplicate completion items filterCompletionDuplicates: false, + + # Condenses the completion menu items to single (key-)words (plus kind) + condensedCompletionMenu: false, } # set the LSP plugin options from the user provided option values diff --git a/doc/lsp.txt b/doc/lsp.txt index 46318ac..46e6e02 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -684,6 +684,12 @@ filterCompletionDuplicates |Boolean| option. If enabled, duplicate completion items sent from the server will be filtered to only include one instance of the duplicates. + *lsp-opt-condensedCompletionMenu* +condensedCompletionMenu |Boolean| option. If enabled, minimizes completion + menu items to single (key-) words (plus kind). + Moves all additional details to info popup. + Caveat: LazyDoc will override moved details! + For example, to disable the automatic placement of signs for the LSP diagnostic messages, you can add the following line to your .vimrc file: > -- 2.48.1