Skip to content

Commit

Permalink
Add g:LanguageClient_useFloatingHover
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Mar 21, 2019
1 parent 04dce37 commit 0fbded1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 8 additions & 3 deletions autoload/LanguageClient.vim
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ function! s:GetVar(...) abort
endif
endfunction

function! s:ShouldUseFloatWindow() abort
return s:FLOAT_WINDOW_AVAILABLE && get(g:, 'LanguageClient_useFloatingHover', 1)
endfunction

function! s:CloseFloatingHoverOnCursorMove(win_id, opened) abort
if getpos('.') == a:opened
" Just after opening floating window, CursorMoved event is run.
Expand Down Expand Up @@ -304,7 +308,8 @@ function! s:OpenHoverPreview(bufname, lines, filetype) abort
let lines = a:lines
let bufnr = bufnr('%')

if s:FLOAT_WINDOW_AVAILABLE
let use_float_win = s:ShouldUseFloatWindow()
if use_float_win
let pos = getpos('.')

" Calculate width and height and give margin to lines
Expand Down Expand Up @@ -371,7 +376,7 @@ function! s:OpenHoverPreview(bufname, lines, filetype) abort

wincmd p

if s:FLOAT_WINDOW_AVAILABLE
if use_float_win
" Unlike preview window, :pclose does not close window. Instead, close
" hover window automatically when cursor is moved.
let call_after_move = printf('<SID>CloseFloatingHoverOnCursorMove(%d, %s)', float_win_id, string(pos))
Expand Down Expand Up @@ -664,7 +669,7 @@ function! LanguageClient#Notify(method, params) abort
endfunction

function! LanguageClient#textDocument_hover(...) abort
if s:FLOAT_WINDOW_AVAILABLE && s:MoveIntoHoverPreview()
if s:ShouldUseFloatWindow() && s:MoveIntoHoverPreview()
return
endif
let l:Callback = get(a:000, 1, v:null)
Expand Down
10 changes: 10 additions & 0 deletions doc/LanguageClient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,16 @@ Specify whether to use virtual text to display diagnostics.
Default: 1 whenever virtual text is supported.
Valid Options: 1 | 0

2.26 g:LanguageClient_useFloatingHover *g:LanguageClient_useFloatingHover*

When the value is set to 1, |LanguageClient#textDocument_hover()| opens
documentation in a floating window instead of preview.
This variable is effective only when the floating window feature is
supported.

Default: 1 when a floating window is supported, otherwise 0
Valid Options: 1 | 0

==============================================================================
3. Commands *LanguageClientCommands*

Expand Down

0 comments on commit 0fbded1

Please sign in to comment.