From 1122f9c333ab7a1e328627d21f2425b4e8bcaa71 Mon Sep 17 00:00:00 2001 From: newtonne <14221622+newtonne@users.noreply.github.com> Date: Sun, 14 May 2023 13:51:19 +0100 Subject: [PATCH] Add `keepFocusInDiags` option This option serves a similar purpose to `keepFocusInReferences` but for `LspDiagShow` rather than `LspShowReferences`. No changes to default behaviour since it defaults to true. --- autoload/lsp/diag.vim | 5 +++++ autoload/lsp/options.vim | 2 ++ doc/lsp.txt | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index f812c40..a0dede4 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -410,12 +410,17 @@ enddef # Display the diagnostic messages from the LSP server for the current buffer # in a location list export def ShowAllDiags(): void + var save_winid = win_getid() + if !DiagsUpdateLocList(bufnr()) util.WarnMsg($'No diagnostic messages found for {@%}') return endif :lopen + if !opt.lspOptions.keepFocusInDiags + save_winid->win_gotoid() + endif enddef # Display the message of 'diag' in a popup window right below the position in diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index 8e29c79..2253dfd 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -31,6 +31,8 @@ export var lspOptions: dict = { hoverInPreview: false, # Don't print message when a configured language server is missing. ignoreMissingServer: false, + # Focus on the location list window after LspDiagShow + keepFocusInDiags: true, # Focus on the location list window after LspShowReferences keepFocusInReferences: false, # If true, apply the LSP server supplied text edits after a completion. diff --git a/doc/lsp.txt b/doc/lsp.txt index 7ce342a..8e819bd 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -438,6 +438,10 @@ hoverInPreview |Boolean| option. Show |:LspHover| in a preview window *lsp-opt-ignoreMissingServer* ignoreMissingServer |Boolean| option. Do not print a missing language server executable. By default this is set to false. + *lsp-opt-keepFocusInDiags* +keepFocusInDiags |Boolean| option. Focus on the location list window + after LspDiagShow. + By default this is set to true. *lsp-opt-keepFocusInReferences* keepFocusInReferences |Boolean| option. Focus on the location list window after LspShowReferences. -- 2.50.0