mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-25 02:57:20 +08:00
#1532 - Display hover information on CursorHold
This commit is contained in:
@@ -147,6 +147,10 @@ function! ale#events#Init() abort
|
||||
autocmd InsertLeave * if exists('*ale#engine#Cleanup') | call ale#virtualtext#ShowCursorWarning() | endif
|
||||
endif
|
||||
|
||||
if g:ale_hover_cursor
|
||||
autocmd CursorHold * if exists('*ale#lsp#Send') | call ale#hover#ShowTruncatedMessageAtCursor() | endif
|
||||
endif
|
||||
|
||||
if g:ale_close_preview_on_insert
|
||||
autocmd InsertEnter * if exists('*ale#preview#CloseIfTypeMatches') | call ale#preview#CloseIfTypeMatches('ale-preview') | endif
|
||||
endif
|
||||
|
||||
@@ -42,6 +42,8 @@ function! ale#hover#HandleTSServerResponse(conn_id, response) abort
|
||||
\&& exists('*balloon_show')
|
||||
\&& ale#Var(l:options.buffer, 'set_balloons')
|
||||
call balloon_show(a:response.body.displayString)
|
||||
elseif get(l:options, 'truncated_echo', 0)
|
||||
call ale#cursor#TruncatedEcho(split(a:response.body.displayString, "\n")[0])
|
||||
elseif g:ale_hover_to_preview
|
||||
call ale#preview#Show(split(a:response.body.displayString, "\n"), {
|
||||
\ 'filetype': 'ale-preview.message',
|
||||
@@ -156,6 +158,7 @@ function! s:OnReady(line, column, opt, linter, lsp_details) abort
|
||||
\ 'column': l:column,
|
||||
\ 'hover_from_balloonexpr': get(a:opt, 'called_from_balloonexpr', 0),
|
||||
\ 'show_documentation': get(a:opt, 'show_documentation', 0),
|
||||
\ 'truncated_echo': get(a:opt, 'truncated_echo', 0),
|
||||
\}
|
||||
endfunction
|
||||
|
||||
@@ -189,6 +192,16 @@ function! ale#hover#ShowAtCursor() abort
|
||||
call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], {})
|
||||
endfunction
|
||||
|
||||
function! ale#hover#ShowTruncatedMessageAtCursor() abort
|
||||
let l:buffer = bufnr('')
|
||||
let [l:info, l:loc] = ale#util#FindItemAtCursor(l:buffer)
|
||||
|
||||
if empty(l:loc)
|
||||
let l:pos = getpos('.')
|
||||
call ale#hover#Show(l:buffer, l:pos[1], l:pos[2], {'truncated_echo': 1})
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" This function implements the :ALEDocumentation command.
|
||||
function! ale#hover#ShowDocumentationAtCursor() abort
|
||||
let l:buffer = bufnr('')
|
||||
|
||||
Reference in New Issue
Block a user