From d8411f21d2e69450cf8557b4bfa6550aefdc0391 Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Sun, 2 Apr 2023 22:52:06 +0200 Subject: [PATCH] Move "inlayhint" support check inside the "inlayhint#BufferInit" function --- autoload/lsp/inlayhints.vim | 13 ++++++++++++- autoload/lsp/lsp.vim | 6 ------ 2 files changed, 12 insertions(+), 7 deletions(-) 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, -- 2.48.1