@@ -35,12 +35,17 @@ function! lsp#ui#vim#definition(in_preview, ...) abort
35
35
call s: list_location (' definition' , l: ctx )
36
36
endfunction
37
37
38
- function ! lsp#ui#vim#references () abort
39
- let l: ctx = { ' jump_if_one' : 0 }
38
+ function ! lsp#ui#vim#references (ctx ) abort
39
+ let l: ctx = extend ( { ' jump_if_one' : 0 }, a: ctx )
40
40
let l: request_params = { ' context' : { ' includeDeclaration' : v: false } }
41
41
call s: list_location (' references' , l: ctx , l: request_params )
42
42
endfunction
43
43
44
+ function ! lsp#ui#vim#add_tree_references () abort
45
+ let l: ctx = { ' add_tree' : v: true }
46
+ call lsp#ui#vim#references (l: ctx )
47
+ endfunction
48
+
44
49
function ! s: list_location (method, ctx, ... ) abort
45
50
" typeDefinition => type definition
46
51
let l: operation = substitute (a: method , ' \u' , ' \l\0' , ' g' )
@@ -307,10 +312,21 @@ function! s:handle_location(ctx, server, type, data) abort "ctx = {counter, list
307
312
echo ' Retrieved ' . a: type
308
313
redraw
309
314
elseif ! a: ctx [' in_preview' ]
315
+ if get (a: ctx , ' add_tree' , v: false )
316
+ let l: qf = getqflist ({' idx' : 0 , ' items' : []})
317
+ let l: pos = l: qf .idx
318
+ let l: parent = l: qf .items
319
+ let l: level = count (l: parent [l: pos- 1 ].text, g: lsp_tree_incoming_prefix )
320
+ let a: ctx [' list' ] = extend (l: parent , map (a: ctx [' list' ], ' extend(v:val, {"text": repeat("' . g: lsp_tree_incoming_prefix . ' ", l:level+1) . v:val.text})' ), l: pos )
321
+ endif
310
322
call setqflist ([])
311
323
call setqflist (a: ctx [' list' ])
312
324
echo ' Retrieved ' . a: type
313
325
botright copen
326
+ if get (a: ctx , ' add_tree' , v: false )
327
+ " move the cursor to the newly added item
328
+ execute l: pos + 1
329
+ endif
314
330
else
315
331
let l: lines = readfile (l: loc [' filename' ])
316
332
if has_key (l: loc ,' viewstart' ) " showing a locationLink
0 commit comments