From: Andreas Louv Date: Sun, 12 Mar 2023 17:47:32 +0000 (+0100) Subject: Fix "showDiagOnStatusLine", as it didn't work X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=418057586c9de09b6047c706f957384866bb72c7;p=vim-lsp.git Fix "showDiagOnStatusLine", as it didn't work By moving the option check inside the BufferInit function, the user have had a change to set the option before it's being checked. --- diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 827b7bc..4cc7d32 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -262,6 +262,14 @@ def AddBufLocalAutocmds(lspserver: dict, 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 diff --git a/plugin/lsp.vim b/plugin/lsp.vim index f374cfc..f2f4aab 100644 --- a/plugin/lsp.vim +++ b/plugin/lsp.vim @@ -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('')->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?