mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -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
|
|
@ -240,7 +240,7 @@ jsx (queries only)[^jsx] | unstable | `HFIJ ` | @steelsojka
|
|||
[rnoweb](https://github.com/bamonroe/tree-sitter-rnoweb) | unstable | `HF J ` | @bamonroe
|
||||
[robot](https://github.com/Hubro/tree-sitter-robot) | unstable | `HFIJ ` | @Hubro
|
||||
[robots](https://github.com/opa-oz/tree-sitter-robots-txt) | unstable | `H J ` | @opa-oz
|
||||
[roc](https://github.com/faldor20/tree-sitter-roc) | unstable | `H JL` | @nat-418
|
||||
[roc](https://github.com/faldor20/tree-sitter-roc) | unstable | `H IJL` | @nat-418
|
||||
[ron](https://github.com/tree-sitter-grammars/tree-sitter-ron) | unstable | `HFIJL` | @amaanq
|
||||
[rst](https://github.com/stsewd/tree-sitter-rst) | unstable | `H JL` | @stsewd
|
||||
[ruby](https://github.com/tree-sitter/tree-sitter-ruby) | unstable | `HFIJL` | @TravonteD
|
||||
|
|
@ -282,6 +282,7 @@ jsx (queries only)[^jsx] | unstable | `HFIJ ` | @steelsojka
|
|||
[tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) | unstable | `HFIJ ` | @lewis6991
|
||||
[teal](https://github.com/euclidianAce/tree-sitter-teal) | unstable | `HFIJL` | @euclidianAce
|
||||
[templ](https://github.com/vrischmann/tree-sitter-templ) | unstable | `HF J ` | @vrischmann
|
||||
[tera](https://github.com/uncenter/tree-sitter-tera) | unstable | `H J ` | @uncenter
|
||||
[terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) | unstable | `HFIJ ` | @MichaHoffmann
|
||||
[textproto](https://github.com/PorterAtGoogle/tree-sitter-textproto) | unstable | `HFIJ ` | @Porter
|
||||
[thrift](https://github.com/tree-sitter-grammars/tree-sitter-thrift) | unstable | `HFIJL` | @amaanq, @duskmoon314
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ return {
|
|||
angular = {
|
||||
install_info = {
|
||||
generate_from_json = true,
|
||||
revision = '745d3c65c2294aca1110b6b6ad6805124be605c9',
|
||||
revision = 'cba288924f4832abb619c627539f111004ff22e5',
|
||||
url = 'https://github.com/dlvandenberg/tree-sitter-angular',
|
||||
},
|
||||
maintainers = { '@dlvandenberg' },
|
||||
|
|
@ -47,7 +47,7 @@ return {
|
|||
},
|
||||
asm = {
|
||||
install_info = {
|
||||
revision = '5bb5b03e3c1ce5853b5282b9fba060f7c7bbf11e',
|
||||
revision = '04962e15f6b464cf1d75eada59506dc25090e186',
|
||||
url = 'https://github.com/RubixDev/tree-sitter-asm',
|
||||
},
|
||||
maintainers = { '@RubixDev' },
|
||||
|
|
@ -225,7 +225,7 @@ return {
|
|||
},
|
||||
cmake = {
|
||||
install_info = {
|
||||
revision = 'cd00bbcb77fe31283ca79b0038387ec7411759ae',
|
||||
revision = 'c70336e8db6d3842721d9be40610580908ff45ba',
|
||||
url = 'https://github.com/uyha/tree-sitter-cmake',
|
||||
},
|
||||
maintainers = { '@uyha' },
|
||||
|
|
@ -518,7 +518,7 @@ return {
|
|||
},
|
||||
erlang = {
|
||||
install_info = {
|
||||
revision = '370cea629eb62a8686504b9fb3252a5e1ae55313',
|
||||
revision = '364e323b32d098ad0e7b29e7adb4005c2bb5cf34',
|
||||
url = 'https://github.com/WhatsApp/tree-sitter-erlang',
|
||||
},
|
||||
maintainers = { '@filmor' },
|
||||
|
|
@ -708,7 +708,7 @@ return {
|
|||
},
|
||||
gleam = {
|
||||
install_info = {
|
||||
revision = 'af6043419f5aa0f8b6c2a26db0187aefa46c7f5f',
|
||||
revision = 'e01c88449b53e2ee5dad222d4020cc7006c5b700',
|
||||
url = 'https://github.com/gleam-lang/tree-sitter-gleam',
|
||||
},
|
||||
maintainers = { '@amaanq' },
|
||||
|
|
@ -1032,7 +1032,7 @@ return {
|
|||
},
|
||||
ini = {
|
||||
install_info = {
|
||||
revision = '962568c9efa71d25720ab42c5d36e222626ef3a6',
|
||||
revision = '32b31863f222bf22eb43b07d4e9be8017e36fb31',
|
||||
url = 'https://github.com/justinmk/tree-sitter-ini',
|
||||
},
|
||||
maintainers = { '@theHamsta' },
|
||||
|
|
@ -1100,7 +1100,7 @@ return {
|
|||
jinja = {
|
||||
install_info = {
|
||||
location = 'tree-sitter-jinja',
|
||||
revision = '07a62adf99c0f41e0cab7ab523541309a8d73dc4',
|
||||
revision = '9af6ce9380fabd3d5b19d0254b8c8936e879c471',
|
||||
url = 'https://github.com/cathaysia/tree-sitter-jinja',
|
||||
},
|
||||
maintainers = { '@cathaysia' },
|
||||
|
|
@ -1111,7 +1111,7 @@ return {
|
|||
jinja_inline = {
|
||||
install_info = {
|
||||
location = 'tree-sitter-jinja_inline',
|
||||
revision = '07a62adf99c0f41e0cab7ab523541309a8d73dc4',
|
||||
revision = '9af6ce9380fabd3d5b19d0254b8c8936e879c471',
|
||||
url = 'https://github.com/cathaysia/tree-sitter-jinja',
|
||||
},
|
||||
maintainers = { '@cathaysia' },
|
||||
|
|
@ -1399,7 +1399,7 @@ return {
|
|||
},
|
||||
meson = {
|
||||
install_info = {
|
||||
revision = '12edaf0dfef0a43bc74336a4432b2db1c65788d6',
|
||||
revision = '742a21e11e914096e0172dad2f0b85e7554c95ff',
|
||||
url = 'https://github.com/tree-sitter-grammars/tree-sitter-meson',
|
||||
},
|
||||
maintainers = { '@Decodetalkers' },
|
||||
|
|
@ -1408,7 +1408,7 @@ return {
|
|||
mlir = {
|
||||
install_info = {
|
||||
generate = true,
|
||||
revision = 'af14b427119a7428b461277bfc43abe5864d995d',
|
||||
revision = 'c7c62f37a8612a897d25906d93363fec36c1591c',
|
||||
url = 'https://github.com/artagnon/tree-sitter-mlir',
|
||||
},
|
||||
maintainers = { '@artagnon' },
|
||||
|
|
@ -1472,7 +1472,7 @@ return {
|
|||
},
|
||||
nix = {
|
||||
install_info = {
|
||||
revision = '48057cf966641e7a49b09700550751195c34bcb5',
|
||||
revision = 'cfc53fd287d23ab7281440a8526c73542984669b',
|
||||
url = 'https://github.com/cstrahan/tree-sitter-nix',
|
||||
},
|
||||
maintainers = { '@leo60228' },
|
||||
|
|
@ -1489,7 +1489,7 @@ return {
|
|||
},
|
||||
nu = {
|
||||
install_info = {
|
||||
revision = 'b99dc3b7b26337d84f95c0de4dda81077b03e5c7',
|
||||
revision = 'c10340b5bb3789f69182acf8f34c3d4fc24d2fe1',
|
||||
url = 'https://github.com/nushell/tree-sitter-nu',
|
||||
},
|
||||
maintainers = { '@abhisheksingh0x558' },
|
||||
|
|
@ -1516,7 +1516,7 @@ return {
|
|||
ocaml = {
|
||||
install_info = {
|
||||
location = 'grammars/ocaml',
|
||||
revision = 'db52ba3f7f33c9949bba115a813d7c30a359cd87',
|
||||
revision = '91708deb10cb4fe68ab3c50891426b9967dbf35a',
|
||||
url = 'https://github.com/tree-sitter/tree-sitter-ocaml',
|
||||
},
|
||||
maintainers = { '@undu' },
|
||||
|
|
@ -1525,7 +1525,7 @@ return {
|
|||
ocaml_interface = {
|
||||
install_info = {
|
||||
location = 'grammars/interface',
|
||||
revision = 'db52ba3f7f33c9949bba115a813d7c30a359cd87',
|
||||
revision = '91708deb10cb4fe68ab3c50891426b9967dbf35a',
|
||||
url = 'https://github.com/tree-sitter/tree-sitter-ocaml',
|
||||
},
|
||||
maintainers = { '@undu' },
|
||||
|
|
@ -1535,7 +1535,7 @@ return {
|
|||
ocamllex = {
|
||||
install_info = {
|
||||
generate = true,
|
||||
revision = '5da5bb7508ac9fd3317561670ef18c126a0fe2aa',
|
||||
revision = 'c5cf996c23e38a1537069fbe2d4bb83a75fc7b2f',
|
||||
url = 'https://github.com/atom-ocaml/tree-sitter-ocamllex',
|
||||
},
|
||||
maintainers = { '@undu' },
|
||||
|
|
@ -1942,7 +1942,7 @@ return {
|
|||
},
|
||||
roc = {
|
||||
install_info = {
|
||||
revision = 'de0839d6c7db2405e827435cf3ac62d22f4bd5e9',
|
||||
revision = '32e20cb1133a5a189f986c3b5df47ac730fbee3d',
|
||||
url = 'https://github.com/faldor20/tree-sitter-roc',
|
||||
},
|
||||
maintainers = { '@nat-418' },
|
||||
|
|
@ -1982,7 +1982,7 @@ return {
|
|||
},
|
||||
rust = {
|
||||
install_info = {
|
||||
revision = '02da1b25f6dfc7341ddb80f37f708cdd9301be2d',
|
||||
revision = 'e86119bdb4968b9799f6a014ca2401c178d54b5f',
|
||||
url = 'https://github.com/tree-sitter/tree-sitter-rust',
|
||||
},
|
||||
maintainers = { '@amaanq' },
|
||||
|
|
@ -1990,7 +1990,7 @@ return {
|
|||
},
|
||||
scala = {
|
||||
install_info = {
|
||||
revision = 'd67fe3ba3879bd7ba74bd7f56c9a38fed241ba25',
|
||||
revision = 'ed939ed550ebff7d4ad8aafb4d5aad44de69965d',
|
||||
url = 'https://github.com/tree-sitter/tree-sitter-scala',
|
||||
},
|
||||
maintainers = { '@stevanmilic' },
|
||||
|
|
@ -2188,7 +2188,7 @@ return {
|
|||
superhtml = {
|
||||
install_info = {
|
||||
location = 'tree-sitter-superhtml',
|
||||
revision = '15ff939100f9d52342445407973f3ce125a8437e',
|
||||
revision = '91d92846e8baaafc8854d2b9d0ac436bc16234db',
|
||||
url = 'https://github.com/kristoff-it/superhtml',
|
||||
},
|
||||
maintainers = { '@rockorager' },
|
||||
|
|
@ -2223,7 +2223,7 @@ return {
|
|||
swift = {
|
||||
install_info = {
|
||||
generate = true,
|
||||
revision = '42ad8f6b4dc9b46285893cc37b460323b54932d4',
|
||||
revision = '02db52e14bc303322d22019fff7823d72904dfe5',
|
||||
url = 'https://github.com/alex-pinkus/tree-sitter-swift',
|
||||
},
|
||||
maintainers = { '@alex-pinkus' },
|
||||
|
|
@ -2277,14 +2277,6 @@ return {
|
|||
maintainers = { '@lewis6991' },
|
||||
tier = 2,
|
||||
},
|
||||
tera = {
|
||||
install_info = {
|
||||
url = 'https://github.com/uncenter/tree-sitter-tera',
|
||||
files = { 'src/parser.c', 'src/scanner.c' },
|
||||
},
|
||||
maintainers = { '@uncenter' },
|
||||
tier = 2,
|
||||
},
|
||||
teal = {
|
||||
install_info = {
|
||||
generate = true,
|
||||
|
|
@ -2303,6 +2295,14 @@ return {
|
|||
maintainers = { '@vrischmann' },
|
||||
tier = 2,
|
||||
},
|
||||
tera = {
|
||||
install_info = {
|
||||
revision = '588f14ce363904bebd926492bbd1d2c53f8d5f14',
|
||||
url = 'https://github.com/uncenter/tree-sitter-tera',
|
||||
},
|
||||
maintainers = { '@uncenter' },
|
||||
tier = 2,
|
||||
},
|
||||
terraform = {
|
||||
install_info = {
|
||||
location = 'dialects/terraform',
|
||||
|
|
@ -2460,7 +2460,7 @@ return {
|
|||
unison = {
|
||||
install_info = {
|
||||
generate = true,
|
||||
revision = '3c97db76d3cdbd002dfba493620c2d5df2fd6fa9',
|
||||
revision = '169e7f748a540ec360c0cb086b448faad012caa4',
|
||||
url = 'https://github.com/kylegoetz/tree-sitter-unison',
|
||||
},
|
||||
maintainers = { '@tapegram' },
|
||||
|
|
@ -2517,7 +2517,7 @@ return {
|
|||
},
|
||||
vhdl = {
|
||||
install_info = {
|
||||
revision = 'db1d7446bd07d811981734cd501fe1994cbad99d',
|
||||
revision = '32d3e3daa745bf9f1665676f323be968444619e1',
|
||||
url = 'https://github.com/jpt13653903/tree-sitter-vhdl',
|
||||
},
|
||||
maintainers = { '@jpt13653903' },
|
||||
|
|
@ -2668,7 +2668,7 @@ return {
|
|||
ziggy = {
|
||||
install_info = {
|
||||
location = 'tree-sitter-ziggy',
|
||||
revision = 'af41bdb5b1d64404c2ec7eb1d9de01083c0d2596',
|
||||
revision = '00958faeaeb97d9b7beb76f128a5401441182204',
|
||||
url = 'https://github.com/kristoff-it/ziggy',
|
||||
},
|
||||
maintainers = { '@rockorager' },
|
||||
|
|
@ -2677,7 +2677,7 @@ return {
|
|||
ziggy_schema = {
|
||||
install_info = {
|
||||
location = 'tree-sitter-ziggy-schema',
|
||||
revision = 'af41bdb5b1d64404c2ec7eb1d9de01083c0d2596',
|
||||
revision = '00958faeaeb97d9b7beb76f128a5401441182204',
|
||||
url = 'https://github.com/kristoff-it/ziggy',
|
||||
},
|
||||
maintainers = { '@rockorager' },
|
||||
|
|
|
|||
|
|
@ -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