]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Make it possible to use the quickfix list for locations
authorAndreas Louv <andreas@louv.dk>
Sat, 1 Apr 2023 18:42:05 +0000 (20:42 +0200)
committerAndreas Louv <andreas@louv.dk>
Sat, 1 Apr 2023 20:13:44 +0000 (22:13 +0200)
Locations can come from ":LspShowReferences" but also
":LspGotoDefinition", when there are multiple matches.

autoload/lsp/options.vim
autoload/lsp/symbol.vim
doc/lsp.txt

index 2a779d0927b8469ea8b4ad631286d8fe4c3601e7..b80b03dd9afe0e64a7d96033ff049d6238a2e3cd 100644 (file)
@@ -72,6 +72,8 @@ export var lspOptions: dict<any> = {
   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
index db0b590ebf7591c0d3a8e0b7503a6641b396825c..4c99a2aa1996d9554efe1a273cc4409b8484b3c0 100644 (file)
@@ -376,9 +376,17 @@ export def ShowLocations(lspserver: dict<any>, locations: list<dict<any>>,
   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
index ed38318338ea5b2e59f18d8443c06e141711c2dc..394a72f52d0211347f887a3b2273886bb79b95f4 100644 (file)
@@ -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