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

Commit

Permalink
Fix some v:null errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdevries committed Jan 30, 2017
1 parent 554008e commit 41143f4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
6 changes: 3 additions & 3 deletions autoload/langserver/callbacks.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ endfunction

function! langserver#callbacks#data(id, data, event) abort
call langserver#log#callback(a:id, a:data, a:event)
let g:last_response = a:data

if type(a:data) != type({})
return ''
return {}
endif

if has_key(a:data, 'response')
let l:parsed_data = a:data['response']['result']
else
return ''
return {}
endif

let g:last_response = l:parsed_data
return l:parsed_data
endfunction
22 changes: 19 additions & 3 deletions autoload/langserver/hover.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
function! langserver#hover#callback(id, data, event) abort
let l:parsed_data = langserver#callbacks#data(a:id, a:data, a:event)

if langserver#util#null_check(l:parsed_data)
call langserver#hover#display([], [
\ {
\ 'language': 'LSP',
\ 'value': 'Unable to retrieve hover information'
\ },
\ ],
\ )
return
endif

if l:parsed_data == {}
return
endif
Expand Down Expand Up @@ -41,9 +53,13 @@ function! langserver#hover#display(range, data) abort

echo l:hover_string

return timer_start(3000, function('s:delete_highlight'))
if !empty(a:range)
return timer_start(3000, function('s:delete_highlight'))
endif
endfunction

function! s:delete_highlight() abort
silent! call matchdelete(s:my_last_highlight)
function! s:delete_highlight(timer_id) abort
if exists('s:my_last_highlight')
silent! call matchdelete(s:my_last_highlight)
endif
endfunction
8 changes: 8 additions & 0 deletions autoload/langserver/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,11 @@ function! langserver#util#get_line(loc_bufnr, loc_filename, loc_line) abort

return l:loc_text
endfunction

function! langserver#util#null_check(item)
if type(a:item) == type(v:null)
return v:true
else
return v:false
endif
endfunction

0 comments on commit 41143f4

Please sign in to comment.