mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
* fix comment
* fix indent
* support diagnostics in a floating window
* doc: add g:lsp_diagnostics_float_{cursor,delay}
* fix vint errors except unused variables
* suppress vint unused variable errors
* lint: use robust operator
35 lines
1.2 KiB
VimL
35 lines
1.2 KiB
VimL
function! lsp#ui#vim#diagnostics#echo#cursor_moved() abort
|
|
if mode() isnot# 'n'
|
|
" show echo only in normal mode
|
|
return
|
|
endif
|
|
|
|
call s:stop_cursor_moved_timer()
|
|
|
|
let l:current_pos = getcurpos()[0:2]
|
|
|
|
" use timer to avoid recalculation
|
|
if !exists('s:last_pos') || l:current_pos != s:last_pos
|
|
let s:last_pos = l:current_pos
|
|
let s:cursor_moved_timer = timer_start(g:lsp_diagnostics_echo_delay, function('s:echo_diagnostics_under_cursor'))
|
|
endif
|
|
endfunction
|
|
|
|
function! s:echo_diagnostics_under_cursor(...) abort
|
|
let l:diagnostic = lsp#ui#vim#diagnostics#get_diagnostics_under_cursor()
|
|
if !empty(l:diagnostic) && has_key(l:diagnostic, 'message')
|
|
call lsp#utils#echo_with_truncation('LSP: '. substitute(l:diagnostic['message'], '\n\+', ' ', 'g'))
|
|
let s:displaying_message = 1
|
|
elseif get(s:, 'displaying_message', 0)
|
|
call lsp#utils#echo_with_truncation('')
|
|
let s:displaying_message = 0
|
|
endif
|
|
endfunction
|
|
|
|
function! s:stop_cursor_moved_timer() abort
|
|
if exists('s:cursor_moved_timer')
|
|
call timer_stop(s:cursor_moved_timer)
|
|
unlet s:cursor_moved_timer
|
|
endif
|
|
endfunction
|