aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorprzepompownia <przepompownia@users.noreply.github.com>2025-03-05 20:03:30 +0100
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit6fe00326406d1aedd0383c4b8b5e7c1ae02197b0 (patch)
tree6db2ca93b0544801b652ea4d9132d3888152025b /scripts
parentfix(install): early return if parser_info does not exist (diff)
downloadnvim-treesitter-6fe00326406d1aedd0383c4b8b5e7c1ae02197b0.tar
nvim-treesitter-6fe00326406d1aedd0383c4b8b5e7c1ae02197b0.tar.gz
nvim-treesitter-6fe00326406d1aedd0383c4b8b5e7c1ae02197b0.tar.bz2
nvim-treesitter-6fe00326406d1aedd0383c4b8b5e7c1ae02197b0.tar.lz
nvim-treesitter-6fe00326406d1aedd0383c4b8b5e7c1ae02197b0.tar.xz
nvim-treesitter-6fe00326406d1aedd0383c4b8b5e7c1ae02197b0.tar.zst
nvim-treesitter-6fe00326406d1aedd0383c4b8b5e7c1ae02197b0.zip
feat(install): allow pass callback to `update()`
Problem: cannot run `:TSUpdate synchronously` Solution: pass callback used after exiting jobs (like in `install-parsers`).
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/install-parsers.lua21
1 files changed, 15 insertions, 6 deletions
diff --git a/scripts/install-parsers.lua b/scripts/install-parsers.lua
index 36be0b9c4..cb7389e19 100755
--- a/scripts/install-parsers.lua
+++ b/scripts/install-parsers.lua
@@ -1,11 +1,14 @@
#!/usr/bin/env -S nvim -l
local generate = false
+local update = false
local max_jobs = nil ---@as integer
local parsers = {}
for i = 1, #_G.arg do
if _G.arg[i] == '--generate' then
generate = true
+ elseif _G.arg[i] == '--update' then
+ update = true
elseif _G.arg[i]:find('^%-%-max%-jobs') then
max_jobs = _G.arg[i]:match('=(%d+)')
else
@@ -19,13 +22,19 @@ vim.opt.runtimepath:append('.')
vim.fn.mkdir(vim.fn.stdpath('cache'), 'p')
local ok = nil
-require('nvim-treesitter.install').install(
- #parsers > 0 and parsers or 'all',
- { force = true, generate = generate, max_jobs = max_jobs },
- function(success)
+if update then
+ require('nvim-treesitter.install').update('all', {}, function(success)
ok = success
- end
-)
+ end)
+else
+ require('nvim-treesitter.install').install(
+ #parsers > 0 and parsers or 'all',
+ { force = true, generate = generate, max_jobs = max_jobs },
+ function(success)
+ ok = success
+ end
+ )
+end
vim.wait(6000000, function()
return ok ~= nil