diff --git a/README.md b/README.md index 0260e9ccf..703a41781 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,9 @@ Parsers and queries can then be installed with require'nvim-treesitter'.install { 'rust', 'javascript', 'zig' } ``` -(This is a no-op if the parsers are already installed.) Note that this function runs asynchronously; for synchronous installation in a script context ("bootstrapping"), use something like +(This is a no-op if the parsers are already installed.) Note that this function runs asynchronously; for synchronous installation in a script context ("bootstrapping"), you need to `wait()` for it to finish: ```lua -require('nvim-treesitter').install({ 'rust', 'javascript', 'zig' }):wait(3000000) +require('nvim-treesitter').install({ 'rust', 'javascript', 'zig' }):wait(300000) -- wait max. 5 minutes ``` Check [`:h nvim-treesitter-commands`](doc/nvim-treesitter.txt) for a list of all available commands. diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index eac35e356..b57687961 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -112,7 +112,7 @@ install({languages} [, {opts}]) *nvim-treesitter.install()* synchronous operation (e.g., in a bootstrapping script), you need to `wait()` for it: >lua require('nvim-treesitter').install({ 'rust', 'javascript', 'zig' }) - :wait(3000000) + :wait(300000) -- max. 5 minutes < Parameters: ~ • {languages} `(string[]|string)` (List of) languages or tiers (`stable`, @@ -142,7 +142,7 @@ update([{languages}]) *nvim-treesitter.update() Note: This operation is performed asynchronously by default. For synchronous operation (e.g., in a bootstrapping script), you need to `wait()` for it: >lua - require('nvim-treesitter').update():wait(3000000) + require('nvim-treesitter').update():wait(300000) -- max. 5 minutes < Parameters: ~ • {languages} `(string[]|string)?` (List of) languages or tiers to update diff --git a/scripts/install-parsers.lua b/scripts/install-parsers.lua index 7fb41fd1e..f06d3ee46 100755 --- a/scripts/install-parsers.lua +++ b/scripts/install-parsers.lua @@ -21,19 +21,14 @@ vim.opt.runtimepath:append('.') -- needed on CI vim.fn.mkdir(vim.fn.stdpath('cache'), 'p') -local task = nil -if update then - --- @type async.Task - task = require('nvim-treesitter.install').update('all') -else - --- @type async.Task - task = require('nvim-treesitter.install').install( +---@type async.Task +local task = update and require('nvim-treesitter.install').update('all') + or require('nvim-treesitter.install').install( #parsers > 0 and parsers or 'all', { force = true, generate = generate, max_jobs = max_jobs } ) -end -local ok, err_or_ok = task:pwait(6000000) +local ok, err_or_ok = task:pwait(1800000) -- wait max. 30 minutes if not ok then print('ERROR: ', err_or_ok) vim.cmd.cq()