Skip to content

Commit 99ced29

Browse files
committed
fix hover for s-k hit
1 parent 76c7094 commit 99ced29

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

autoload/easycomplete.vim

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,15 @@ function! s:CompleteMenuResetHandler(...)
18261826
endif
18271827
endfunction
18281828

1829+
function! s:Has_Shift_K_Map()
1830+
let maps = execute('map <s-k>')
1831+
if maps =~ "EasyCompleteHover"
1832+
return v:true
1833+
else
1834+
return v:false
1835+
endif
1836+
endfunction
1837+
18291838
function! easycomplete#CompleteAdd(menu_list, plugin_name)
18301839
if !s:CheckCompleteTaskQueueAllDone()
18311840
if s:zizzing() | return | endif
@@ -2914,8 +2923,10 @@ endfunction
29142923

29152924
function! easycomplete#HoverNothing(msg)
29162925
call s:log(a:msg)
2917-
let cw = expand('<cword>')
2918-
exec "help " . cw
2926+
if s:Has_Shift_K_Map()
2927+
let cw = expand('<cword>')
2928+
exec "h " . cw
2929+
endif
29192930
endfunction
29202931

29212932
function! easycomplete#BackToOriginalBuffer()

autoload/easycomplete/action/hover.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ function! s:do()
2323
let l:server = l:servers[0]
2424
let has_provider = easycomplete#lsp#HasProvider(l:server, "hoverProvider")
2525
if has_provider == 0
26+
if s:Has_Shift_K_Map()
27+
exec "h ". expand('<cword>')
28+
endif
2629
return
2730
endif
2831

@@ -37,22 +40,40 @@ function! s:do()
3740
\ })
3841
endfunction
3942

43+
function! s:Has_Shift_K_Map()
44+
let maps = execute('map <s-k>')
45+
if maps =~ "EasyCompleteHover"
46+
return v:true
47+
else
48+
return v:false
49+
endif
50+
endfunction
51+
4052
function! s:HandleLspCallback(server, data) abort
4153
try
4254
if easycomplete#lsp#client#is_error(a:data['response'])
4355
call easycomplete#lsp#utils#error('Failed ' . a:server)
4456
call s:flush()
57+
if s:Has_Shift_K_Map()
58+
exec "h ". expand('<cword>')
59+
endif
4560
return
4661
endif
4762

4863
if !has_key(a:data['response'], 'result')
4964
call s:flush()
65+
if s:Has_Shift_K_Map()
66+
exec "h ". expand('<cword>')
67+
endif
5068
return
5169
endif
5270

5371
let local_msg = s:get(a:data,"response","result","contents","value")
5472
if empty(local_msg)
5573
call s:log("No hover informations!")
74+
if s:Has_Shift_K_Map()
75+
exec "h ". expand('<cword>')
76+
endif
5677
return
5778
endif
5879
let content = substitute(local_msg, "```\\w\\+", "", "g")
@@ -61,6 +82,8 @@ function! s:HandleLspCallback(server, data) abort
6182
let content = s:RemoveTrailingEmptyStrings(content)
6283
if !empty(content)
6384
call easycomplete#popup#float(content, 'Pmenu', 0, "", [0, 0], 'signature')
85+
elseif s:Has_Shift_K_Map()
86+
exec "h ". expand('<cword>')
6487
endif
6588
return
6689
catch

0 commit comments

Comments
 (0)