mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
Problem: Many parsers require node/npm to evaluate the `grammar.js` before being able to generate a parser from it. Solution: Generate from `grammar.json` instead, which is fully resolved. Drops `node` and `npm` as (optional) requirements for nvim-treesitter. Note that this requires parsers to commit the generated json iff the grammar requires evaluation (which is currently the case for all tracked languages).
29 lines
523 B
Lua
Executable file
29 lines
523 B
Lua
Executable file
#!/usr/bin/env -S nvim -l
|
|
|
|
local generate = false
|
|
local parsers = {}
|
|
for i = 1, #_G.arg do
|
|
if _G.arg[i] == '--generate' then
|
|
generate = true
|
|
else
|
|
parsers[#parsers + 1] = _G.arg[i]
|
|
end
|
|
end
|
|
|
|
vim.opt.runtimepath:append('.')
|
|
|
|
-- needed on CI
|
|
vim.fn.mkdir(vim.fn.stdpath('cache'), 'p')
|
|
|
|
local done = false
|
|
require('nvim-treesitter.install').install(
|
|
#parsers > 0 and parsers or 'all',
|
|
{ force = true, generate = generate },
|
|
function()
|
|
done = true
|
|
end
|
|
)
|
|
|
|
vim.wait(6000000, function()
|
|
return done
|
|
end)
|