health.lua 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. local M = {}
  2. local ts = vim.treesitter
  3. local health = vim.health
  4. --- Performs a healthcheck for treesitter integration
  5. function M.check()
  6. health.start('Treesitter features')
  7. health.info(
  8. string.format(
  9. 'Treesitter ABI support: min %d, max %d',
  10. vim.treesitter.minimum_language_version,
  11. ts.language_version
  12. )
  13. )
  14. local can_wasm = vim._ts_add_language_from_wasm ~= nil
  15. health.info(string.format('WASM parser support: %s', tostring(can_wasm)))
  16. health.start('Treesitter parsers')
  17. local parsers = vim.api.nvim_get_runtime_file('parser/*', true)
  18. for _, parser in pairs(parsers) do
  19. local parsername = vim.fn.fnamemodify(parser, ':t:r')
  20. local is_loadable, err_or_nil = pcall(ts.language.add, parsername)
  21. if not is_loadable then
  22. health.error(
  23. string.format(
  24. 'Parser "%s" failed to load (path: %s): %s',
  25. parsername,
  26. parser,
  27. err_or_nil or '?'
  28. )
  29. )
  30. else
  31. local lang = ts.language.inspect(parsername)
  32. health.ok(
  33. string.format('Parser: %-20s ABI: %d, path: %s', parsername, lang._abi_version, parser)
  34. )
  35. end
  36. end
  37. end
  38. return M