From: Andreas Louv Date: Sat, 1 Apr 2023 18:42:05 +0000 (+0200) Subject: Make it possible to use the quickfix list for locations X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=f0a8e3201221aebcc5848a4243e4177e40c7d9fb;p=vim-lsp.git Make it possible to use the quickfix list for locations Locations can come from ":LspShowReferences" but also ":LspGotoDefinition", when there are multiple matches. --- diff --git a/autoload/lsp/options.vim b/autoload/lsp/options.vim index 2a779d0..b80b03d 100644 --- a/autoload/lsp/options.vim +++ b/autoload/lsp/options.vim @@ -72,6 +72,8 @@ export var lspOptions: dict = { diagSignInfoTexthl: 'Pmenu', diagSignHintText: 'H>', diagSignHintTexthl: 'Question', + # ShowReferences in a quickfix list instead of a location list` + useQuickfixForLocations: false } # set the LSP plugin options from the user provided option values diff --git a/autoload/lsp/symbol.vim b/autoload/lsp/symbol.vim index db0b590..4c99a2a 100644 --- a/autoload/lsp/symbol.vim +++ b/autoload/lsp/symbol.vim @@ -376,9 +376,17 @@ export def ShowLocations(lspserver: dict, locations: list>, endfor var save_winid = win_getid() - setloclist(0, [], ' ', {title: title, items: qflist}) - var mods: string = '' - exe $'{mods} lopen' + + if opt.lspOptions.useQuickfixForLocations + setqflist([], ' ', {title: title, items: qflist}) + var mods: string = '' + exe $'{mods} copen' + else + setloclist(0, [], ' ', {title: title, items: qflist}) + var mods: string = '' + exe $'{mods} lopen' + endif + if !opt.lspOptions.keepFocusInReferences save_winid->win_gotoid() endif diff --git a/doc/lsp.txt b/doc/lsp.txt index ed38318..394a72f 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -344,6 +344,9 @@ outlineOnRight |Boolean| option. Open the outline window on the right side, by default this is false. outlineWinSize |Number| option. The size of the symbol Outline window. By default this is set to 20. +useQuickfixForLocations |Boolean| option. Show |:LspShowReferences| in a + quickfix list instead of a location list. + By default this is set to false. showDiagInPopup |Boolean| option. When using the |:LspDiagCurrent| command to display the diagnostic message for the current line, use a popup window to display the @@ -671,7 +674,13 @@ can map these commands to keys and make it easier to invoke them. *:LspShowReferences* :LspShowReferences Creates a new location list with the list of locations where the symbol under the cursor is referenced and - opens the location window. + opens the location window. If you want to show the + references in a quickfix list instead of in a location + list set > + + call LspOptionsSet({'useQuickfixForLocations': v:true}) +< + Set ' :LspShowServerCapabilities *:LspShowServerCapabilities* Display the list of language server capabilities for