health.lua 856 B

12345678910111213141516171819202122232425262728
  1. local M = {}
  2. --- Performs a healthcheck for LSP
  3. function M.check()
  4. local report_info = vim.fn['health#report_info']
  5. local report_warn = vim.fn['health#report_warn']
  6. local log = require('vim.lsp.log')
  7. local current_log_level = log.get_level()
  8. local log_level_string = log.levels[current_log_level]
  9. report_info(string.format("LSP log level : %s", log_level_string))
  10. if current_log_level < log.levels.WARN then
  11. report_warn(string.format("Log level %s will cause degraded performance and high disk usage", log_level_string))
  12. end
  13. local log_path = vim.lsp.get_log_path()
  14. report_info(string.format("Log path: %s", log_path))
  15. local log_size = vim.loop.fs_stat(log_path).size
  16. local report_fn = (log_size / 1000000 > 100 and report_warn or report_info)
  17. report_fn(string.format("Log size: %d KB", log_size / 1000 ))
  18. end
  19. return M