From: Gregory Anders Date: Wed, 30 Mar 2022 16:04:21 +0000 (-0600) Subject: Add option to automatically populate location list with diagnostics X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4d5c1a348558704f2ad960d7f572e1181ed4ae9d;p=vim-lsp.git Add option to automatically populate location list with diagnostics --- diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 72801a5..c9423ef 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -44,6 +44,10 @@ enddef # 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 + ShowAllDiags(lspserver, false) + endif + if !opt.lspOptions.autoHighlightDiags return endif @@ -152,7 +156,7 @@ enddef # Display the diagnostic messages from the LSP server for the current buffer # in a location list -export def ShowAllDiags(lspserver: dict): void +export def ShowAllDiags(lspserver: dict, open = true): void var fname: string = expand('%:p') if fname == '' return @@ -177,7 +181,9 @@ export def ShowAllDiags(lspserver: dict): void endfor setloclist(0, [], ' ', {'title': 'Language Server Diagnostics', 'items': qflist}) - :lopen + if open + :lopen + endif enddef # Show the diagnostic message for the current line diff --git a/autoload/lsp/lspoptions.vim b/autoload/lsp/lspoptions.vim index b5bc6ce..c189546 100644 --- a/autoload/lsp/lspoptions.vim +++ b/autoload/lsp/lspoptions.vim @@ -15,6 +15,8 @@ export var lspOptions: dict = { echoSignature: false, # Automatically highlight diagnostics messages from LSP server autoHighlightDiags: true, + # Automatically populate the location list with new diagnostics + autoPopulateDiags: false, # Show the symbol documentation in the preview window instead of in a popup hoverInPreview: false, # Focus on the location list window after LspShowReferences diff --git a/doc/lsp.txt b/doc/lsp.txt index 0ad70a0..c05402e 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -212,6 +212,9 @@ echoSignature In insert mode, echo the current symbol signature autoHighlightDiags Automatically place signs on the lines with a diagnostic message from the LSP server. By default this is set to true. +autoPopulateDiags Automatically populate the location list with + diagnostics from the LSP server. By default this is + set to false. keepFocusInReferences Focus on the location list window after LspShowReferences. By default this is set to false. noNewlineInCompletion Suppress adding a new line on completion selection