mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat(install): allow pass callback to update()
Problem: cannot run `:TSUpdate synchronously` Solution: pass callback used after exiting jobs (like in `install-parsers`).
This commit is contained in:
parent
02a1a0537c
commit
6fe0032640
4 changed files with 56 additions and 43 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue