All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " internal state for whether it is enabled or not to avoid multiple subscriptions
4 function! lsp#internal#diagnostics#echo#_enable() abort
5 " don't even bother registering if the feature is disabled
6 if !g:lsp_diagnostics_echo_cursor | return | endif
8 if s:enabled | return | endif
11 let s:Dispose = lsp#callbag#pipe(
12 \ lsp#callbag#fromEvent(['CursorMoved']),
13 \ lsp#callbag#filter({_->g:lsp_diagnostics_echo_cursor}),
14 \ lsp#callbag#debounceTime(g:lsp_diagnostics_echo_delay),
15 \ lsp#callbag#map({_->{'bufnr': bufnr('%'), 'curpos': getcurpos()[0:2], 'changedtick': b:changedtick }}),
16 \ lsp#callbag#distinctUntilChanged({a,b -> a['bufnr'] == b['bufnr'] && a['curpos'] == b['curpos'] && a['changedtick'] == b['changedtick']}),
17 \ lsp#callbag#filter({_->mode() is# 'n'}),
18 \ lsp#callbag#filter({_->getbufvar(bufnr('%'), '&buftype') !=# 'terminal' }),
19 \ lsp#callbag#map({_->lsp#internal#diagnostics#under_cursor#get_diagnostic()}),
20 \ lsp#callbag#subscribe({x->s:echo(x)}),
24 function! lsp#internal#diagnostics#echo#_disable() abort
25 if !s:enabled | return | endif
26 if exists('s:Dispose')
33 function! s:echo(diagnostic) abort
34 if !empty(a:diagnostic) && has_key(a:diagnostic, 'message')
35 call lsp#utils#echo_with_truncation('LSP: '. substitute(a:diagnostic['message'], '\n\+', ' ', 'g'))
36 let s:displaying_message = 1
37 elseif get(s:, 'displaying_message', 0)
38 call lsp#utils#echo_with_truncation('')
39 let s:displaying_message = 0