mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-14 01:10:02 -04:00
Use installed parsers in CI check
This commit is contained in:
parent
28bc7a0703
commit
d727fffe41
1 changed files with 15 additions and 19 deletions
|
|
@ -21,7 +21,7 @@ local function extract_captures()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_check()
|
local function do_check()
|
||||||
local parsers = require 'nvim-treesitter.parsers'.available_parsers()
|
local parsers = require 'nvim-treesitter.info'.installed_parsers()
|
||||||
local queries = require 'nvim-treesitter.query'
|
local queries = require 'nvim-treesitter.query'
|
||||||
local query_types = queries.built_in_query_groups
|
local query_types = queries.built_in_query_groups
|
||||||
|
|
||||||
|
|
@ -29,28 +29,24 @@ local function do_check()
|
||||||
local last_error
|
local last_error
|
||||||
|
|
||||||
for _, lang in pairs(parsers) do
|
for _, lang in pairs(parsers) do
|
||||||
if parsers.has_parser(lang) then
|
for _, query_type in pairs(query_types) do
|
||||||
for _, query_type in pairs(query_types) do
|
print('Checking '..lang..' '..query_type)
|
||||||
print('Checking '..lang..' '..query_type)
|
local ok, query = pcall(queries.get_query,lang, query_type)
|
||||||
local ok, query = pcall(queries.get_query,lang, query_type)
|
if not ok then
|
||||||
if not ok then
|
vim.api.nvim_err_writeln(query)
|
||||||
vim.api.nvim_err_writeln(query)
|
last_error = query
|
||||||
last_error = query
|
else
|
||||||
else
|
if query then
|
||||||
if query then
|
for _, capture in ipairs(query.captures) do
|
||||||
for _, capture in ipairs(query.captures) do
|
if not vim.startswith(capture, "_") -- We ignore things like _helper
|
||||||
if not vim.startswith(capture, "_") -- We ignore things like _helper
|
and captures[query_type]
|
||||||
and captures[query_type]
|
and not capture:find("^[A-Z]") -- Highlight groups
|
||||||
and not capture:find("^[A-Z]") -- Highlight groups
|
and not vim.tbl_contains(captures[query_type], capture) then
|
||||||
and not vim.tbl_contains(captures[query_type], capture) then
|
error(string.format("Invalid capture @%s in %s for %s.", capture, query_type, lang))
|
||||||
error(string.format("Invalid capture @%s in %s for %s.", capture, query_type, lang))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
print("No parser for "..lang.." installed! Skipping...")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if last_error then
|
if last_error then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue