Print workspace_config with :verbose LspStatus (#1279)

* Make verbose LspStatus show workspace config

Need the trailing echo to ensure the next lsp server is on a new line.

* Use pretty printing if available

* checkhealth: Print server status and config

Add initial checkhealth support.
See https://github.com/rhysd/vim-healthcheck

Lists server status, advice for failure, and lists workspace config to
help debug issues or understand server state. Doesn't do much error
detecting.

* checkhealth: Print each server config as a section

checkhealth doesn't allow a lot of formatting (no indentation), so it's
hard to make the config output readable. Output each server as a
separate section instead of one giant config block to make the start of
each server easier to see.
This commit is contained in:
David Briscoe
2022-10-29 10:43:57 -07:00
committed by GitHub
parent 9d4dbf7e68
commit 0c8fda7921
4 changed files with 100 additions and 2 deletions

View File

@@ -148,7 +148,22 @@ let s:color_map = {
\ 'not running': 'Comment'
\}
" Print the current status of all servers (if called with no arguments)
" Collect the current status of all servers
function! lsp#collect_server_status() abort
let l:results = {}
for l:k in keys(s:servers)
let l:status = s:server_status(l:k)
" Copy to prevent callers from corrupting our config.
let l:info = deepcopy(s:servers[l:k].server_info)
let l:results[l:k] = {
\ 'status': l:status,
\ 'info': l:info,
\ }
endfor
return l:results
endfunction
" Print the current status of all servers
function! lsp#print_server_status() abort
for l:k in sort(keys(s:servers))
let l:status = s:server_status(l:k)
@@ -157,6 +172,15 @@ function! lsp#print_server_status() abort
echon l:status
echohl None
echo ''
if &verbose
let l:cfg = { 'workspace_config': s:servers[l:k].server_info.workspace_config }
if get(g:, 'loaded_scriptease', 0)
call scriptease#pp_command(0, -1, l:cfg)
else
echo json_encode(l:cfg)
endif
echo ''
endif
endfor
endfunction