Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Commit

Permalink
Add line reader helper
Browse files Browse the repository at this point in the history
  • Loading branch information
TJ DeVries committed Nov 18, 2016
1 parent 91ba01f commit cf7cf98
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autoload/langserver/references.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion autoload/langserver/symbol/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let s:symbol_kind = {
\ 17: 'Boolean',
\ 18: 'Array',
\ },
\ }
\ }


function! langserver#symbol#util#transform_reply(message) abort
Expand Down
10 changes: 10 additions & 0 deletions autoload/langserver/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cf7cf98

Please sign in to comment.