]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add support for toggling inlay hints
authorYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 23 Sep 2024 03:12:08 +0000 (20:12 -0700)
committerYegappan Lakshmanan <yegappan@yahoo.com>
Mon, 23 Sep 2024 03:12:08 +0000 (20:12 -0700)
autoload/lsp/inlayhints.vim
autoload/lsp/lsp.vim
doc/lsp.txt

index a79369973216784a1af4276c59b4185ec52d6e39..5030c9543bb761c3bb881be7f97ae9fa0f6207f2 100644 (file)
@@ -222,6 +222,15 @@ export def InlayHintsDisable()
   save_showInlayHints = false
 enddef
 
+# Toggle (enable or disable) inlay hints.
+export def InlayHintsToggle()
+  if opt.lspOptions.showInlayHints
+    InlayHintsDisable()
+  else
+    InlayHintsEnable()
+  endif
+enddef
+
 # Some options are changed.  If 'showInlayHints' option is changed, then
 # either enable or disable inlay hints.
 export def LspInlayHintsOptionsChanged()
index 83f1f4d351dd9f91f212656c85c4e40e665ebb9b..154f861e9e08e91922b899717e5c4b944da70927 100644 (file)
@@ -809,6 +809,8 @@ export def InlayHints(ctl: string)
     inlayhints.InlayHintsEnable()
   elseif ctl == 'disable'
     inlayhints.InlayHintsDisable()
+  elseif ctl == 'toggle'
+    inlayhints.InlayHintsToggle()
   else
     util.ErrMsg($'LspInlayHints - Unsupported argument "{ctl}"')
   endif
@@ -816,7 +818,7 @@ enddef
 
 # Command-line completion for the ":LspInlayHints" command
 export def LspInlayHintsComplete(arglead: string, cmdline: string, cursorPos: number): list<string>
-  var l = ['enable', 'disable']
+  var l = ['enable', 'disable', 'toggle']
   return filter(l, (_, val) => val =~ $'^{arglead}')
 enddef
 
index a40da7ad52b361c95b713b6ba29fcdfcd06f7ccc..a318be4b0678b60e29fa7eb7fd0b5492c69ca913 100644 (file)
@@ -117,7 +117,7 @@ The following commands are provided:
                        in a popup window.
 :LspIncomingCalls      Display the list of symbols calling the current symbol
                        in a window.
-:LspInlayHints         Enable or disable inlay hints.
+:LspInlayHints         Enable or disable or toggle inlay hints.
 :LspOutgoingCalls      Display the list of symbols called by the current
                        symbol in a window.
 :LspOutline            Show the list of symbols defined in the current file
@@ -937,11 +937,13 @@ can map these commands to keys and make it easier to invoke them.
                        not all the language servers support this feature.
 
                                                *:LspInlayHints*
-:LspInlayHints         Enable or disable inlay hints.  Supports the "enable"
-                       and "disable" arguments.  When "enable" is specified,
-                       enables the inlay hints for all the buffers with a
-                       language server that supports inlay hints.  When
-                       "disable" is specified, disables the inlay hints.
+:LspInlayHints         Enable or disable inlay hints.  Supports the "enable",
+                       "disable" and "toggle" arguments.  When "enable" is
+                       specified, enables the inlay hints for all the buffers
+                       with a language server that supports inlay hints.
+                       When "disable" is specified, disables the inlay hints.
+                       When "toggle" is specified, either enables or disables
+                       the inlay hints.
 
                                                *:LspOutoingCalls*
 :LspOutgoingCalls      Display a hierarchy of symbols called by the symbol