From: Andreas Louv Date: Sun, 2 Apr 2023 20:52:06 +0000 (+0200) Subject: Move "inlayhint" support check inside the "inlayhint#BufferInit" function X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=d8411f21d2e69450cf8557b4bfa6550aefdc0391;p=vim-lsp.git Move "inlayhint" support check inside the "inlayhint#BufferInit" function --- diff --git a/autoload/lsp/inlayhints.vim b/autoload/lsp/inlayhints.vim index 7c29d09..b10c722 100644 --- a/autoload/lsp/inlayhints.vim +++ b/autoload/lsp/inlayhints.vim @@ -4,6 +4,7 @@ vim9script import './util.vim' import './buffer.vim' as buf +import './options.vim' as opt # Initialize the highlight group and the text property type used for # inlay hints. @@ -103,7 +104,17 @@ def LspInlayHintsUpdateStop() enddef # Do buffer-local initialization for displaying inlay hints -export def BufferInit(bnr: number) +export def BufferInit(lspserver: dict, bnr: number) + if !lspserver.isInlayHintProvider && !lspserver.isClangdInlayHintsProvider + # no support for inley hints + return + endif + + # Inlays hints are disabled + if !opt.lspOptions.showInlayHints + return + endif + var acmds: list> = [] # Update the inlay hints (if needed) when the cursor is not moved for some diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index f66b957..3f9be04 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -300,12 +300,6 @@ def AddBufLocalAutocmds(lspserver: dict, bnr: number): void cmd: 'call LspDocHighlightClear() | call LspDocHighlight()'}) endif - # Displaying inlay hints needs the Vim virtual text support. - if opt.lspOptions.showInlayHints && (lspserver.isInlayHintProvider - || lspserver.isClangdInlayHintsProvider) - inlayhints.BufferInit(bnr) - endif - # Show diagnostics on the status line if opt.lspOptions.showDiagOnStatusLine acmds->add({bufnr: bnr,