]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Move "inlayhint" support check inside the "inlayhint#BufferInit" function
authorAndreas Louv <andreas@louv.dk>
Sun, 2 Apr 2023 20:52:06 +0000 (22:52 +0200)
committerAndreas Louv <andreas@louv.dk>
Sun, 2 Apr 2023 20:57:35 +0000 (22:57 +0200)
autoload/lsp/inlayhints.vim
autoload/lsp/lsp.vim

index 7c29d0968207b54dd54e1d51c4704341a6c83cfc..b10c722a5c156d01f5f258c61cad50fa01698528 100644 (file)
@@ -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<any>, 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<dict<any>> = []
 
   # Update the inlay hints (if needed) when the cursor is not moved for some
index f66b957af05b085ceb314e97363d4cfd85e456d0..3f9be040354698dfad98fe8869abee58d92efa83 100644 (file)
@@ -300,12 +300,6 @@ def AddBufLocalAutocmds(lspserver: dict<any>, 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,