]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/vim-lsp/autoload/lsp/internal/diagnostics/echo.vim

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit '294584081929424aec883f90c7d6515b3743358d' as '.vim/bundle/vim-lsp-ale'
[etc/vim.git] / .vim / bundle / vim-lsp / autoload / lsp / internal / diagnostics / echo.vim
1 " internal state for whether it is enabled or not to avoid multiple subscriptions
2 let s:enabled = 0
3
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
7
8     if s:enabled | return | endif
9     let s:enabled = 1
10
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)}),
21         \ )
22 endfunction
23
24 function! lsp#internal#diagnostics#echo#_disable() abort
25     if !s:enabled | return | endif
26     if exists('s:Dispose')
27         call s:Dispose()
28         unlet s:Dispose
29     endif
30     let s:enabled = 0
31 endfunction
32
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
40     endif
41 endfunction