diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2024-04-18 09:44:38 +0200 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 5a38df5627fd0658223bdf32c9d6a87e32eb9504 (patch) | |
| tree | f2752a561d3cd7eb9c491f5882b2abeb85f77940 /scripts | |
| parent | bot(readme): update (diff) | |
| download | nvim-treesitter-5a38df5627fd0658223bdf32c9d6a87e32eb9504.tar nvim-treesitter-5a38df5627fd0658223bdf32c9d6a87e32eb9504.tar.gz nvim-treesitter-5a38df5627fd0658223bdf32c9d6a87e32eb9504.tar.bz2 nvim-treesitter-5a38df5627fd0658223bdf32c9d6a87e32eb9504.tar.lz nvim-treesitter-5a38df5627fd0658223bdf32c9d6a87e32eb9504.tar.xz nvim-treesitter-5a38df5627fd0658223bdf32c9d6a87e32eb9504.tar.zst nvim-treesitter-5a38df5627fd0658223bdf32c9d6a87e32eb9504.zip | |
feat(install)!: generate from json instead of requiring node
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).
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/install-parsers.lua | 20 | ||||
| -rwxr-xr-x | scripts/update-readme.lua | 11 |
2 files changed, 20 insertions, 11 deletions
diff --git a/scripts/install-parsers.lua b/scripts/install-parsers.lua index ab06e538f..c607e51f4 100755 --- a/scripts/install-parsers.lua +++ b/scripts/install-parsers.lua @@ -1,14 +1,28 @@ #!/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('all', {}, function() - done = true -end) +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 diff --git a/scripts/update-readme.lua b/scripts/update-readme.lua index fb9a9b32c..f8346bf4d 100755 --- a/scripts/update-readme.lua +++ b/scripts/update-readme.lua @@ -15,8 +15,8 @@ table.sort(sorted_parsers, function(a, b) end) local generated_text = [[ -Language | Tier | Queries | CLI | NPM | Maintainer --------- |:----:|:-------:|:---:|:---:| ---------- +Language | Tier | Queries | CLI | Maintainer +-------- |:----:|:-------:|:---:| ---------- ]] local footnotes = '' @@ -59,12 +59,7 @@ for _, v in ipairs(sorted_parsers) do -- CLI generated_text = generated_text - .. (p.install_info and p.install_info.requires_generate_from_grammar and '✓' or '') - .. ' | ' - - -- NPM - generated_text = generated_text - .. (p.install_info and p.install_info.generate_requires_npm and '✓' or '') + .. (p.install_info and p.install_info.generate and '✓' or '') .. ' | ' -- Maintainer |
