neovim/runtime/lua/vim/treesitter/health.lua

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
877 B
Lua
Raw Normal View History

2021-03-23 15:32:45 -07:00
local M = {}
local ts = vim.treesitter
local health = vim.health
2021-03-23 15:32:45 -07:00
--- Performs a healthcheck for treesitter integration
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
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
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 '?'
)
)
2023-02-27 08:33:18 -07:00
else
local lang = ts.language.inspect(parsername)
health.ok(
string.format('Parser: %-20s ABI: %d, path: %s', parsername, lang._abi_version, parser)
)
2021-03-23 15:32:45 -07:00
end
end
end
return M