From 6fe00326406d1aedd0383c4b8b5e7c1ae02197b0 Mon Sep 17 00:00:00 2001 From: przepompownia Date: Wed, 5 Mar 2025 20:03:30 +0100 Subject: feat(install): allow pass callback to `update()` Problem: cannot run `:TSUpdate synchronously` Solution: pass callback used after exiting jobs (like in `install-parsers`). --- scripts/install-parsers.lua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'scripts') 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 -- cgit v1.2.3-70-g09d2