autoload/lsp/inlayhints.vim | 9 +++++++++ autoload/lsp/lsp.vim | 4 +++- doc/lsp.txt | 14 ++++++++------ diff --git a/autoload/lsp/inlayhints.vim b/autoload/lsp/inlayhints.vim index a79369973216784a1af4276c59b4185ec52d6e39..5030c9543bb761c3bb881be7f97ae9fa0f6207f2 100644 --- a/autoload/lsp/inlayhints.vim +++ b/autoload/lsp/inlayhints.vim @@ -222,6 +222,15 @@ endfor 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() diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 83f1f4d351dd9f91f212656c85c4e40e665ebb9b..154f861e9e08e91922b899717e5c4b944da70927 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -809,6 +809,8 @@ if ctl == 'enable' 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 - var l = ['enable', 'disable'] + var l = ['enable', 'disable', 'toggle'] return filter(l, (_, val) => val =~ $'^{arglead}') enddef diff --git a/doc/lsp.txt b/doc/lsp.txt index a40da7ad52b361c95b713b6ba29fcdfcd06f7ccc..a318be4b0678b60e29fa7eb7fd0b5492c69ca913 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -117,7 +117,7 @@ :LspHover Show the documentation for the symbol under the cursor 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 @@ |lsp-call-hierarchy| for more information. Note that 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