2021-03-23 15:32:45 -07:00
|
|
|
local M = {}
|
|
|
|
local ts = vim.treesitter
|
2024-01-22 10:23:28 -07:00
|
|
|
local health = vim.health
|
2021-03-23 15:32:45 -07:00
|
|
|
|
2021-05-01 05:19:48 -07:00
|
|
|
--- Performs a healthcheck for treesitter integration
|
2021-10-05 05:05:33 -07:00
|
|
|
function M.check()
|
2023-02-27 08:33:18 -07:00
|
|
|
local parsers = vim.api.nvim_get_runtime_file('parser/*', true)
|
2021-03-23 15:32:45 -07:00
|
|
|
|
2023-04-15 14:40:48 -07:00
|
|
|
health.info(string.format('Nvim runtime ABI version: %d', ts.language_version))
|
2021-03-23 15:32:45 -07:00
|
|
|
|
|
|
|
for _, parser in pairs(parsers) do
|
|
|
|
local parsername = vim.fn.fnamemodify(parser, ':t:r')
|
2023-02-27 08:33:18 -07:00
|
|
|
local is_loadable, err_or_nil = pcall(ts.language.add, parsername)
|
2021-03-23 15:32:45 -07:00
|
|
|
|
2023-02-27 08:33:18 -07:00
|
|
|
if not is_loadable then
|
2023-04-15 14:40:48 -07:00
|
|
|
health.error(
|
2023-02-27 08:33:18 -07:00
|
|
|
string.format(
|
|
|
|
'Parser "%s" failed to load (path: %s): %s',
|
|
|
|
parsername,
|
|
|
|
parser,
|
|
|
|
err_or_nil or '?'
|
|
|
|
)
|
2022-10-29 22:41:28 -07:00
|
|
|
)
|
2023-02-27 08:33:18 -07:00
|
|
|
else
|
2023-04-01 06:47:20 -07:00
|
|
|
local lang = ts.language.inspect(parsername)
|
2023-04-15 14:40:48 -07:00
|
|
|
health.ok(
|
2024-05-12 15:12:03 -07:00
|
|
|
string.format('Parser: %-20s ABI: %d, path: %s', parsername, lang._abi_version, parser)
|
2022-07-07 09:27:18 -07:00
|
|
|
)
|
2021-03-23 15:32:45 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return M
|