mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Fix making location list from call hierarchy items (#1113)
* fix making location list from call hierarchy items (fix #1112) * use kind and name when detail is not available on handling call hierarchy item
This commit is contained in:
@@ -413,9 +413,12 @@ function! s:handle_call_hierarchy(ctx, server, type, data) abort
|
||||
|
||||
if lsp#client#is_error(a:data['response']) || !has_key(a:data['response'], 'result')
|
||||
call lsp#utils#error('Failed to retrieve '. a:type . ' for ' . a:server . ': ' . lsp#client#error_message(a:data['response']))
|
||||
else
|
||||
elseif a:data['response']['result'] isnot v:null
|
||||
for l:item in a:data['response']['result']
|
||||
let a:ctx['list'] = a:ctx['list'] + lsp#utils#location#_lsp_to_vim_list(l:item[a:ctx['key']])
|
||||
let l:loc = s:hierarchy_item_to_vim(l:item[a:ctx['key']], a:server)
|
||||
if l:loc isnot v:null
|
||||
let a:ctx['list'] += [l:loc]
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
@@ -431,3 +434,25 @@ function! s:handle_call_hierarchy(ctx, server, type, data) abort
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:hierarchy_item_to_vim(item, server) abort
|
||||
let l:uri = a:item['uri']
|
||||
if !lsp#utils#is_file_uri(l:uri)
|
||||
return v:null
|
||||
endif
|
||||
|
||||
let l:path = lsp#utils#uri_to_path(l:uri)
|
||||
let [l:line, l:col] = lsp#utils#position#lsp_to_vim(l:path, a:item['range']['start'])
|
||||
if has_key(a:item, 'detail')
|
||||
let l:text = a:item['detail']
|
||||
else
|
||||
let l:text = '[' . lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, a:item['kind']) . '] ' . a:item['name']
|
||||
endif
|
||||
|
||||
return {
|
||||
\ 'filename': l:path,
|
||||
\ 'lnum': l:line,
|
||||
\ 'col': l:col,
|
||||
\ 'text': l:text,
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user