]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Process the padding value in inlay hints
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 6 Feb 2024 16:01:28 +0000 (08:01 -0800)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 6 Feb 2024 16:01:28 +0000 (08:01 -0800)
autoload/lsp/inlayhints.vim

index e64deb910f54808fd03d0890d944c4067ce1737d..a79369973216784a1af4276c59b4185ec52d6e39 100644 (file)
@@ -49,6 +49,16 @@ export def InlayHintsReply(lspserver: dict<any>, bnr: number, inlayHints: any)
       label = hint.label
     endif
 
+    # add a space before or after the label
+    var padLeft: bool = hint->get('paddingLeft', false)
+    var padRight: bool = hint->get('paddingRight', false)
+    if padLeft
+      label = $' {label}'
+    endif
+    if padRight
+      label = $'{label} '
+    endif
+
     var kind = hint->has_key('kind') ? hint.kind->string() : '1'
     try
       lspserver.decodePosition(bnr, hint.position)
@@ -57,7 +67,6 @@ export def InlayHintsReply(lspserver: dict<any>, bnr: number, inlayHints: any)
        prop_add(hint.position.line + 1, byteIdx + 1,
          {type: 'LspInlayHintsType', text: label, bufnr: bnr})
       elseif kind == "'parameter'" || kind == '2'
-        label = label .. " "
        prop_add(hint.position.line + 1, byteIdx + 1,
          {type: 'LspInlayHintsParam', text: label, bufnr: bnr})
       endif