autoload/lsp/diag.vim | 12 ++++++------ autoload/lsp/lsp.vim | 4 +++- diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index cba1364896707f15d16fb91ed4c134f1ce299e96..d4d128429f1c8350e9b3b5ea3600a4d9e2c3b7b0 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -45,7 +45,7 @@ # New LSP diagnostic messages received from the server for a file. # Update the signs placed in the buffer for this file def ProcessNewDiags(lspserver: dict, bnr: number) if opt.lspOptions.autoPopulateDiags - DiagsUpdateLocList(lspserver) + DiagsUpdateLocList(lspserver, bnr) endif if !opt.lspOptions.autoHighlightDiags @@ -157,15 +157,15 @@ # Update the location list window for the current window with the diagnostic # messages. # Returns true if diagnostics is not empty and false if it is empty. -def DiagsUpdateLocList(lspserver: dict): bool - var fname: string = expand('%:p') +def DiagsUpdateLocList(lspserver: dict, bnr: number): bool + var fname: string = bufname(bnr)->fnamemodify(':p') if fname == '' return false endif - var bnr: number = bufnr() var LspQfId: number = 0 - if exists('b:LspQfId') && getloclist(0, {id: b:LspQfId}).id == b:LspQfId + if bnr->getbufvar('LspQfId', 0) != 0 && + getloclist(0, {id: b:LspQfId}).id == b:LspQfId LspQfId = b:LspQfId endif @@ -203,7 +203,7 @@ # Display the diagnostic messages from the LSP server for the current buffer # in a location list export def ShowAllDiags(lspserver: dict): void - if !DiagsUpdateLocList(lspserver) + if !DiagsUpdateLocList(lspserver, bufnr()) util.WarnMsg('No diagnostic messages found for ' .. @%) return endif diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index 9c8accb18efd737c39ed27d5c6291305e208303c..8dd73dcfc3b4ad468b1be1aa955a58dcafdbe3e8 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -406,7 +406,9 @@ .. 'call LspDocHighlightClear() | call LspDocHighlight()' endif augroup END - doautocmd User LspAttached + if exists('#User#LspAttached') + doautocmd User LspAttached + endif buf.BufLspServerSet(bnr, lspserver) enddef