diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2021-03-07 19:31:09 +0100 |
|---|---|---|
| committer | Kiyan <yazdani.kiyan@protonmail.com> | 2021-03-16 18:52:43 +0100 |
| commit | 28bc7a070372c4ad6cbf3d98d4743b08defc0561 (patch) | |
| tree | ea8f95b291f704cbb479a8052620745f5f061c09 /scripts/check-queries.lua | |
| parent | [docgen] Update README.md (diff) | |
| download | nvim-treesitter-28bc7a070372c4ad6cbf3d98d4743b08defc0561.tar nvim-treesitter-28bc7a070372c4ad6cbf3d98d4743b08defc0561.tar.gz nvim-treesitter-28bc7a070372c4ad6cbf3d98d4743b08defc0561.tar.bz2 nvim-treesitter-28bc7a070372c4ad6cbf3d98d4743b08defc0561.tar.lz nvim-treesitter-28bc7a070372c4ad6cbf3d98d4743b08defc0561.tar.xz nvim-treesitter-28bc7a070372c4ad6cbf3d98d4743b08defc0561.tar.zst nvim-treesitter-28bc7a070372c4ad6cbf3d98d4743b08defc0561.zip | |
Skip parsers in query check that are not installed
Diffstat (limited to 'scripts/check-queries.lua')
| -rwxr-xr-x | scripts/check-queries.lua | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua index 9738272d2..6da143c04 100755 --- a/scripts/check-queries.lua +++ b/scripts/check-queries.lua @@ -29,24 +29,28 @@ local function do_check() local last_error for _, lang in pairs(parsers) do - for _, query_type in pairs(query_types) do - print('Checking '..lang..' '..query_type) - local ok, query = pcall(queries.get_query,lang, query_type) - if not ok then - vim.api.nvim_err_writeln(query) - last_error = query - else - if query then - for _, capture in ipairs(query.captures) do - if not vim.startswith(capture, "_") -- We ignore things like _helper - and captures[query_type] - and not capture:find("^[A-Z]") -- Highlight groups - and not vim.tbl_contains(captures[query_type], capture) then - error(string.format("Invalid capture @%s in %s for %s.", capture, query_type, lang)) + if parsers.has_parser(lang) then + for _, query_type in pairs(query_types) do + print('Checking '..lang..' '..query_type) + local ok, query = pcall(queries.get_query,lang, query_type) + if not ok then + vim.api.nvim_err_writeln(query) + last_error = query + else + if query then + for _, capture in ipairs(query.captures) do + if not vim.startswith(capture, "_") -- We ignore things like _helper + and captures[query_type] + and not capture:find("^[A-Z]") -- Highlight groups + and not vim.tbl_contains(captures[query_type], capture) then + error(string.format("Invalid capture @%s in %s for %s.", capture, query_type, lang)) + end end end end end + else + print("No parser for "..lang.." installed! Skipping...") end end if last_error then |
