2023-05-29 16:52:20 +02:00
|
|
|
#!/usr/bin/env -S nvim -l
|
|
|
|
|
|
2024-04-18 09:44:38 +02:00
|
|
|
local generate = false
|
2025-03-05 20:03:30 +01:00
|
|
|
local update = false
|
2024-05-03 19:55:41 +02:00
|
|
|
local max_jobs = nil ---@type integer?
|
2024-04-18 09:44:38 +02:00
|
|
|
local parsers = {}
|
|
|
|
|
for i = 1, #_G.arg do
|
|
|
|
|
if _G.arg[i] == '--generate' then
|
|
|
|
|
generate = true
|
2025-03-05 20:03:30 +01:00
|
|
|
elseif _G.arg[i] == '--update' then
|
|
|
|
|
update = true
|
2024-08-27 11:02:34 +02:00
|
|
|
elseif _G.arg[i]:find('^%-%-max%-jobs') then
|
|
|
|
|
max_jobs = _G.arg[i]:match('=(%d+)')
|
2024-04-18 09:44:38 +02:00
|
|
|
else
|
2025-04-27 16:08:59 +02:00
|
|
|
parsers[#parsers + 1] = _G.arg[i] ---@type string
|
2024-04-18 09:44:38 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-05-29 16:52:20 +02:00
|
|
|
vim.opt.runtimepath:append('.')
|
|
|
|
|
|
|
|
|
|
-- needed on CI
|
|
|
|
|
vim.fn.mkdir(vim.fn.stdpath('cache'), 'p')
|
|
|
|
|
|
2025-05-16 15:44:26 +01:00
|
|
|
---@type async.Task
|
|
|
|
|
local task = update and require('nvim-treesitter.install').update('all')
|
|
|
|
|
or require('nvim-treesitter.install').install(
|
2025-03-05 20:03:30 +01:00
|
|
|
#parsers > 0 and parsers or 'all',
|
2025-05-16 15:44:26 +01:00
|
|
|
{ force = true, generate = generate, max_jobs = max_jobs }
|
2025-03-05 20:03:30 +01:00
|
|
|
)
|
2023-05-29 16:52:20 +02:00
|
|
|
|
2025-05-16 15:44:26 +01:00
|
|
|
local ok, err_or_ok = task:pwait(1800000) -- wait max. 30 minutes
|
2024-10-12 20:14:21 +02:00
|
|
|
if not ok then
|
2025-05-16 15:44:26 +01:00
|
|
|
print('ERROR: ', err_or_ok)
|
|
|
|
|
vim.cmd.cq()
|
|
|
|
|
elseif not err_or_ok then
|
2024-10-12 20:14:21 +02:00
|
|
|
vim.cmd.cq()
|
|
|
|
|
end
|