]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Fix "showDiagOnStatusLine", as it didn't work
authorAndreas Louv <andreas@louv.dk>
Sun, 12 Mar 2023 17:47:32 +0000 (18:47 +0100)
committerAndreas Louv <andreas@louv.dk>
Sun, 12 Mar 2023 17:53:52 +0000 (18:53 +0100)
By moving the option check inside the BufferInit function, the user have
had a change to set the option before it's being checked.

autoload/lsp/lsp.vim
plugin/lsp.vim

index 827b7bcd74b79c81e7a00beeb24ddd5210422e61..4cc7d32e65312ddfa93d03a903354e2aec02cb5a 100644 (file)
@@ -262,6 +262,14 @@ def AddBufLocalAutocmds(lspserver: dict<any>, bnr: number): void
     inlayhints.BufferInit(bnr)
   endif
 
+  # Show diagnostics on the status line
+  if opt.lspOptions.showDiagOnStatusLine
+    acmds->add({bufnr: bnr,
+               event: 'CursorMoved',
+               group: 'LSPBufferAutocmds',
+               cmd: 'LspShowCurrentDiagInStatusLine()'})
+  endif
+
   autocmd_add(acmds)
 enddef
 
index f374cfca33378a453caba3ad501811d89d5380bd..f2f4aabad39f55595e3516f23500bfd9c06acf1b 100644 (file)
@@ -9,7 +9,7 @@ vim9script
 
 g:loaded_lsp = 1
 
-import autoload '../autoload/lsp/options.vim'
+import '../autoload/lsp/options.vim'
 import autoload '../autoload/lsp/lsp.vim'
 
 
@@ -70,9 +70,6 @@ augroup LSPAutoCmds
   # Note that when BufWipeOut is invoked, the current buffer may be different
   # from the buffer getting wiped out.
   autocmd BufWipeOut * lsp.RemoveFile(expand('<abuf>')->str2nr())
-  if options.lspOptions.showDiagOnStatusLine
-    autocmd CursorMoved * lsp.LspShowCurrentDiagInStatusLine()
-  endif
 augroup END
 
 # TODO: Is it needed to shutdown all the LSP servers when exiting Vim?