aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-03 12:08:14 +0200
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit37957d6bcf88999d41240f81610d29d48364c452 (patch)
tree722c572f6c1960983bf9a1ab1d21e6c113a97751 /scripts
parentfix: install dependencies (diff)
downloadnvim-treesitter-37957d6bcf88999d41240f81610d29d48364c452.tar
nvim-treesitter-37957d6bcf88999d41240f81610d29d48364c452.tar.gz
nvim-treesitter-37957d6bcf88999d41240f81610d29d48364c452.tar.bz2
nvim-treesitter-37957d6bcf88999d41240f81610d29d48364c452.tar.lz
nvim-treesitter-37957d6bcf88999d41240f81610d29d48364c452.tar.xz
nvim-treesitter-37957d6bcf88999d41240f81610d29d48364c452.tar.zst
nvim-treesitter-37957d6bcf88999d41240f81610d29d48364c452.zip
refactor: use `vim.uv`
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-queries.lua72
-rwxr-xr-xscripts/update-readme.lua10
2 files changed, 32 insertions, 50 deletions
diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua
index fd9d538ac..3f5a9aa70 100755
--- a/scripts/check-queries.lua
+++ b/scripts/check-queries.lua
@@ -39,6 +39,7 @@ local function do_check()
local timings = {}
local parsers = require('nvim-treesitter.config').installed_parsers()
local query_types = require('nvim-treesitter.health').bundled_queries
+ local configs = require('nvim-treesitter.parsers').configs
local captures = extract_captures()
local errors = {}
@@ -46,30 +47,32 @@ local function do_check()
io_print('::group::Check parsers')
for _, lang in pairs(parsers) do
- timings[lang] = {}
- for _, query_type in pairs(query_types) do
- local before = vim.loop.hrtime()
- local ok, query = pcall(vim.treesitter.query.get, lang, query_type)
- local after = vim.loop.hrtime()
- local duration = after - before
- table.insert(timings, { duration = duration, lang = lang, query_type = query_type })
- io_print(
- 'Checking ' .. lang .. ' ' .. query_type .. string.format(' (%.02fms)', duration * 1e-6)
- )
- if not ok then
- local err_msg = lang .. ' (' .. query_type .. '): ' .. query
- errors[#errors + 1] = err_msg
- else
- if query then
- for _, capture in ipairs(query.captures) do
- local is_valid = (
- vim.startswith(capture, '_') -- Helpers.
- or vim.list_contains(captures[query_type], capture)
- )
- if not is_valid then
- local error =
- string.format('(x) Invalid capture @%s in %s for %s.', capture, query_type, lang)
- errors[#errors + 1] = error
+ if configs[lang].install_info then
+ timings[lang] = {}
+ for _, query_type in pairs(query_types) do
+ local before = vim.uv.hrtime()
+ local ok, query = pcall(vim.treesitter.query.get, lang, query_type)
+ local after = vim.uv.hrtime()
+ local duration = after - before
+ table.insert(timings, { duration = duration, lang = lang, query_type = query_type })
+ io_print(
+ 'Checking ' .. lang .. ' ' .. query_type .. string.format(' (%.02fms)', duration * 1e-6)
+ )
+ if not ok then
+ local err_msg = lang .. ' (' .. query_type .. '): ' .. query
+ errors[#errors + 1] = err_msg
+ else
+ if query then
+ for _, capture in ipairs(query.captures) do
+ local is_valid = (
+ vim.startswith(capture, '_') -- Helpers.
+ or vim.list_contains(captures[query_type], capture)
+ )
+ if not is_valid then
+ local error =
+ string.format('(x) Invalid capture @%s in %s for %s.', capture, query_type, lang)
+ errors[#errors + 1] = error
+ end
end
end
end
@@ -90,27 +93,6 @@ local function do_check()
end
local ok, result = pcall(do_check)
-local allowed_to_fail = vim.split(vim.env.ALLOWED_INSTALLATION_FAILURES or '', ',', true)
-
-for k, v in pairs(require('nvim-treesitter.parsers').configs) do
- if v.install_info then
- -- skip "query only" languages
- if #vim.api.nvim_get_runtime_file('parser/' .. k .. '.*', false) == 0 then
- -- On CI all parsers that can be installed from C files should be installed
- if
- vim.env.CI
- and not v.install_info.requires_generate_from_grammar
- and not vim.list_contains(allowed_to_fail, k)
- then
- io_print('Error: parser for ' .. k .. ' is not installed')
- vim.cmd('cq')
- else
- io_print('Warning: parser for ' .. k .. ' is not installed')
- end
- end
- end
-end
-
if ok then
io_print('::group::Timings')
table.sort(result, function(a, b)
diff --git a/scripts/update-readme.lua b/scripts/update-readme.lua
index 2133ad0c6..fb9a9b32c 100755
--- a/scripts/update-readme.lua
+++ b/scripts/update-readme.lua
@@ -50,11 +50,11 @@ for _, v in ipairs(sorted_parsers) do
-- queries
generated_text = generated_text
.. '`'
- .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/highlights.scm') and 'H' or ' ')
- .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/folds.scm') and 'F' or ' ')
- .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/indents.scm') and 'I' or ' ')
- .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/injections.scm') and 'J' or ' ')
- .. (vim.loop.fs_stat('runtime/queries/' .. v.name .. '/locals.scm') and 'L' or ' ')
+ .. (vim.uv.fs_stat('runtime/queries/' .. v.name .. '/highlights.scm') and 'H' or ' ')
+ .. (vim.uv.fs_stat('runtime/queries/' .. v.name .. '/folds.scm') and 'F' or ' ')
+ .. (vim.uv.fs_stat('runtime/queries/' .. v.name .. '/indents.scm') and 'I' or ' ')
+ .. (vim.uv.fs_stat('runtime/queries/' .. v.name .. '/injections.scm') and 'J' or ' ')
+ .. (vim.uv.fs_stat('runtime/queries/' .. v.name .. '/locals.scm') and 'L' or ' ')
.. '` | '
-- CLI