]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/vim-lsp/autoload/health/lsp.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 / health / lsp.vim
1 function! s:BuildConfigBlock(section, info) abort
2     let l:block = get(a:info, a:section, '')
3     if !empty(l:block)
4         return printf("### %s\n%s\n", a:section, l:block)
5     endif
6     return ''
7 endf
8
9
10 function! health#lsp#check() abort
11     call s:report_start('server status')
12     let l:server_status = lsp#collect_server_status()
13
14     let l:has_printed = v:false
15     for l:k in sort(keys(l:server_status))
16         let l:report = l:server_status[l:k]
17
18         let l:status_msg = printf('%s: %s', l:k, l:report.status)
19         if l:report.status == 'running'
20             call s:report_ok(l:status_msg)
21         elseif l:report.status == 'failed'
22             call health#report_error(l:status_msg, 'See :help g:lsp_log_verbose to debug server failure.')
23         else
24             call s:report_warn(l:status_msg)
25         endif
26         let l:has_printed = v:true
27     endfor
28
29     if !l:has_printed
30         call s:report_warn('no servers connected')
31     endif
32
33     for l:k in sort(keys(l:server_status))
34         call s:report_start(printf('server configuration: %s', l:k))
35         let l:report = l:server_status[l:k]
36
37         let l:msg = "\t\n"
38         let l:msg .= s:BuildConfigBlock('allowlist', l:report.info)
39         let l:msg .= s:BuildConfigBlock('blocklist', l:report.info)
40         let l:cfg = get(l:report.info, 'workspace_config', '')
41         if !empty(l:cfg)
42             if get(g:, 'loaded_scriptease', 0)
43                 let l:cfg = scriptease#dump(l:cfg, {'width': &columns-1})
44             else
45                 let l:cfg = json_encode(l:cfg)
46                 " Add some whitespace to make it readable.
47                 let l:cfg = substitute(l:cfg, '[,{(\[]', "&\n\t", 'g')
48                 let l:cfg = substitute(l:cfg, '":', '& ', 'g')
49                 let l:cfg = substitute(l:cfg, '\v[})\]]+', "\n&", 'g')
50                 let l:cfg = substitute(l:cfg, '\n\s*\n', "\n", 'g')
51             endif
52             let l:msg .= printf("### workspace_config\n```json\n%s\n```", l:cfg)
53         endif
54         call health#report_info(l:msg)
55     endfor
56
57     call s:report_start('Performance')
58     if lsp#utils#has_lua() && g:lsp_use_lua
59         call s:report_ok('Using lua for faster performance.')
60     else
61         call s:report_warn('Missing requirements to enable lua for faster performance.')
62     endif
63
64 endf
65
66 function! s:report_start(report) abort
67   if has('nvim-0.10')
68     call v:lua.vim.health.start(a:report)
69   else
70     call health#report_start(a:report)
71   endif
72 endf
73
74 function! s:report_warn(report) abort
75   if has('nvim-0.10')
76     call v:lua.vim.health.warn(a:report)
77   else
78     call health#report_warn(a:report)
79   endif
80 endf
81
82 function! s:report_ok(report) abort
83   if has('nvim-0.10')
84     call v:lua.vim.health.ok(a:report)
85   else
86     call health#report_ok(a:report)
87   endif
88 endf