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

Commit 41143f4

Browse files
committed
Fix some v:null errors
1 parent 554008e commit 41143f4

File tree

3 files changed

+30
-6
lines changed

3 files changed

+30
-6
lines changed

Diff for: autoload/langserver/callbacks.vim

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ endfunction
8383

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

8788
if type(a:data) != type({})
88-
return ''
89+
return {}
8990
endif
9091

9192
if has_key(a:data, 'response')
9293
let l:parsed_data = a:data['response']['result']
9394
else
94-
return ''
95+
return {}
9596
endif
9697

97-
let g:last_response = l:parsed_data
9898
return l:parsed_data
9999
endfunction

Diff for: autoload/langserver/hover.vim

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
function! langserver#hover#callback(id, data, event) abort
22
let l:parsed_data = langserver#callbacks#data(a:id, a:data, a:event)
3+
4+
if langserver#util#null_check(l:parsed_data)
5+
call langserver#hover#display([], [
6+
\ {
7+
\ 'language': 'LSP',
8+
\ 'value': 'Unable to retrieve hover information'
9+
\ },
10+
\ ],
11+
\ )
12+
return
13+
endif
14+
315
if l:parsed_data == {}
416
return
517
endif
@@ -41,9 +53,13 @@ function! langserver#hover#display(range, data) abort
4153

4254
echo l:hover_string
4355

44-
return timer_start(3000, function('s:delete_highlight'))
56+
if !empty(a:range)
57+
return timer_start(3000, function('s:delete_highlight'))
58+
endif
4559
endfunction
4660

47-
function! s:delete_highlight() abort
48-
silent! call matchdelete(s:my_last_highlight)
61+
function! s:delete_highlight(timer_id) abort
62+
if exists('s:my_last_highlight')
63+
silent! call matchdelete(s:my_last_highlight)
64+
endif
4965
endfunction

Diff for: autoload/langserver/util.vim

+8
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,11 @@ function! langserver#util#get_line(loc_bufnr, loc_filename, loc_line) abort
286286

287287
return l:loc_text
288288
endfunction
289+
290+
function! langserver#util#null_check(item)
291+
if type(a:item) == type(v:null)
292+
return v:true
293+
else
294+
return v:false
295+
endif
296+
endfunction

0 commit comments

Comments
 (0)