2021-09-07 15:20:15 -07:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
--- Performs a healthcheck for LSP
|
2021-10-05 05:05:33 -07:00
|
|
|
function M.check()
|
2023-04-15 14:40:48 -07:00
|
|
|
local report_info = vim.health.info
|
|
|
|
local report_warn = vim.health.warn
|
2021-09-07 15:20:15 -07:00
|
|
|
|
|
|
|
local log = require('vim.lsp.log')
|
|
|
|
local current_log_level = log.get_level()
|
|
|
|
local log_level_string = log.levels[current_log_level]
|
|
|
|
report_info(string.format('LSP log level : %s', log_level_string))
|
|
|
|
|
|
|
|
if current_log_level < log.levels.WARN then
|
|
|
|
report_warn(
|
|
|
|
string.format(
|
|
|
|
'Log level %s will cause degraded performance and high disk usage',
|
|
|
|
log_level_string
|
|
|
|
)
|
2022-07-07 09:27:18 -07:00
|
|
|
)
|
2021-09-07 15:20:15 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
local log_path = vim.lsp.get_log_path()
|
|
|
|
report_info(string.format('Log path: %s', log_path))
|
|
|
|
|
2023-06-03 03:06:00 -07:00
|
|
|
local log_file = vim.uv.fs_stat(log_path)
|
2022-05-17 11:11:14 -07:00
|
|
|
local log_size = log_file and log_file.size or 0
|
2021-09-07 15:20:15 -07:00
|
|
|
|
|
|
|
local report_fn = (log_size / 1000000 > 100 and report_warn or report_info)
|
|
|
|
report_fn(string.format('Log size: %d KB', log_size / 1000))
|
2023-01-08 01:23:08 -07:00
|
|
|
|
2023-07-17 09:27:16 -07:00
|
|
|
local clients = vim.lsp.get_clients()
|
2023-04-15 14:40:48 -07:00
|
|
|
vim.health.start('vim.lsp: Active Clients')
|
2023-01-08 01:23:08 -07:00
|
|
|
if next(clients) then
|
|
|
|
for _, client in pairs(clients) do
|
|
|
|
report_info(
|
|
|
|
string.format('%s (id=%s, root_dir=%s)', client.name, client.id, client.config.root_dir)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
report_info('No active clients')
|
|
|
|
end
|
2021-09-07 15:20:15 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|