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:
przepompownia 2025-03-05 20:03:30 +01:00 committed by Christian Clason
parent 02a1a0537c
commit 6fe0032640
4 changed files with 56 additions and 43 deletions

View file

@ -455,8 +455,8 @@ end, 3)
---@param languages? string[]|string
---@param _options? UpdateOptions
---@param _callback function
M.update = a.sync(function(languages, _options, _callback)
---@param callback function
M.update = a.sync(function(languages, _options, callback)
reload_parsers()
if not languages or #languages == 0 then
languages = 'all'
@ -465,11 +465,14 @@ M.update = a.sync(function(languages, _options, _callback)
languages = vim.tbl_filter(needs_update, languages) ---@type string[]
if #languages > 0 then
install(languages, { force = true })
install(languages, { force = true }, callback)
else
log.info('All parsers are up-to-date')
if callback then
callback(true)
end
end
end, 2)
end, 3)
---@async
---@param logger Logger