]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add `keepFocusInDiags` option
authornewtonne <14221622+newtonne@users.noreply.github.com>
Sun, 14 May 2023 12:51:19 +0000 (13:51 +0100)
committernewtonne <14221622+newtonne@users.noreply.github.com>
Sun, 14 May 2023 12:51:19 +0000 (13:51 +0100)
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
autoload/lsp/options.vim
doc/lsp.txt

index f812c401aaf0e89cd44b82c37bb6df22b10479b3..a0dede44ec965a3f1ee197ad4e044d139d77ecae 100644 (file)
@@ -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
index 8e29c79e2ae39a0832b7ea49cac7359f601d8242..2253dfdc668d59edfe57f052bfd7d7ef71ed115f 100644 (file)
@@ -31,6 +31,8 @@ export var lspOptions: dict<any> = {
   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.
index 7ce342a0a60210b4d96c845355ef86b8681d0a7a..8e819bdadd216ee3d7b6c0b55a7d4072dd64db18 100644 (file)
@@ -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.