diff --git a/autoload/langserver/references.vim b/autoload/langserver/references.vim index fa3798a..ca2302a 100644 --- a/autoload/langserver/references.vim +++ b/autoload/langserver/references.vim @@ -8,7 +8,7 @@ function! langserver#references#transform_reply(message) abort let l:loc_bufnr = bufnr(langserver#util#get_filename(langserver#util#get_lsp_id(), l:location['uri'])) let l:loc_filename = langserver#util#get_filename(langserver#util#get_lsp_id(), l:location['uri']) let l:loc_line = l:location['range']['start']['line'] + 1 - let l:loc_text = bufnr('%') == l:loc_bufnr ? getline(l:loc_line) : '' + let l:loc_text = langserver#util#get_line(l:loc_bufnr, l:loc_filename, l:loc_line) let l:location_dict = { \ 'filename': l:loc_filename, diff --git a/autoload/langserver/symbol/util.vim b/autoload/langserver/symbol/util.vim index 46eb8cb..c526c4f 100644 --- a/autoload/langserver/symbol/util.vim +++ b/autoload/langserver/symbol/util.vim @@ -39,7 +39,7 @@ let s:symbol_kind = { \ 17: 'Boolean', \ 18: 'Array', \ }, - \ } + \ } function! langserver#symbol#util#transform_reply(message) abort diff --git a/autoload/langserver/util.vim b/autoload/langserver/util.vim index 9ab65c1..ccbaa62 100644 --- a/autoload/langserver/util.vim +++ b/autoload/langserver/util.vim @@ -250,3 +250,13 @@ function! langserver#util#get_lsp_id() abort return -1 endif endfunction + +function! langserver#util#get_line(loc_bufnr, loc_filename, loc_line) abort + if bufnr('%') == a:loc_bufnr + let l:loc_text = getline(a:loc_line) + else + let l:loc_text = readfile(a:loc_filename, '', a:loc_line)[a:loc_line - 1] + endif + + return l:loc_text +endfunction