]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add option to condense completion menu items. (#582)
authorberggeist <24396556+berggeist@users.noreply.github.com>
Tue, 21 Jan 2025 15:31:57 +0000 (16:31 +0100)
committerGitHub <noreply@github.com>
Tue, 21 Jan 2025 15:31:57 +0000 (07:31 -0800)
autoload/lsp/completion.vim
autoload/lsp/options.vim
doc/lsp.txt

index 8ce5899cd03a9c80428cc6b1b871ca315d3a8876..acc6174b96841b4ff5bca51943d03844a0d6095c 100644 (file)
@@ -310,6 +310,26 @@ export def CompletionReply(lspserver: dict<any>, 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
 
index 50697a3bec9b29cc675bbd852df605f758bf8abf..9555e32bfe3bceade5d771f771073c474738a937 100644 (file)
@@ -143,6 +143,9 @@ export var lspOptions: dict<any> = {
 
   # 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
index 46318ac707d9040a79d86bdb122fab0490182f13..46e6e028e3b5767d82b2c0514719afea71c027c2 100644 (file)
@@ -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: >