2023-08-15 20:28:55 +03:00
|
|
|
#!/usr/bin/env -S nvim -l
|
2023-06-12 09:54:30 -06:00
|
|
|
vim.opt.runtimepath:append('.')
|
2023-05-29 16:52:20 +02:00
|
|
|
local util = require('nvim-treesitter.util')
|
2023-02-24 03:07:52 -05:00
|
|
|
|
2023-06-12 09:54:30 -06:00
|
|
|
-- Load previous lockfile
|
2023-05-22 14:35:25 +01:00
|
|
|
local filename = require('nvim-treesitter.install').get_package_path('lockfile.json')
|
2023-05-29 16:52:20 +02:00
|
|
|
local lockfile = vim.json.decode(util.read_file(filename))
|
2023-02-24 03:07:52 -05:00
|
|
|
|
2023-06-12 09:54:30 -06:00
|
|
|
---@type string?
|
2023-05-29 16:52:20 +02:00
|
|
|
local skip_lang_string = os.getenv('LOCKFILE_SKIP')
|
2023-06-12 09:54:30 -06:00
|
|
|
local skip_langs = skip_lang_string and vim.split(skip_lang_string, ',') or {}
|
|
|
|
|
vim.print('Skipping languages: ', skip_langs)
|
|
|
|
|
|
|
|
|
|
local sorted_parsers = {}
|
2023-05-29 16:52:20 +02:00
|
|
|
for k, v in pairs(require('nvim-treesitter.parsers').configs) do
|
2023-06-12 09:54:30 -06:00
|
|
|
table.insert(sorted_parsers, { name = k, parser = v })
|
|
|
|
|
end
|
|
|
|
|
table.sort(sorted_parsers, function(a, b)
|
|
|
|
|
return a.name < b.name
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
-- check for new revisions
|
|
|
|
|
for _, v in ipairs(sorted_parsers) do
|
|
|
|
|
if skip_langs and not vim.list_contains(skip_langs, v.name) then
|
|
|
|
|
local sha ---@type string
|
|
|
|
|
if v.parser.install_info.branch then
|
|
|
|
|
sha = vim.split(
|
|
|
|
|
vim.fn.systemlist(
|
|
|
|
|
'git ls-remote '
|
|
|
|
|
.. v.parser.install_info.url
|
|
|
|
|
.. ' | grep refs/heads/'
|
|
|
|
|
.. v.parser.install_info.branch
|
|
|
|
|
)[1],
|
|
|
|
|
'\t'
|
|
|
|
|
)[1]
|
|
|
|
|
else
|
|
|
|
|
sha = vim.split(vim.fn.systemlist('git ls-remote ' .. v.parser.install_info.url)[1], '\t')[1]
|
|
|
|
|
end
|
|
|
|
|
lockfile[v.name] = { revision = sha }
|
|
|
|
|
print(v.name .. ': ' .. sha)
|
|
|
|
|
else
|
|
|
|
|
print('Skipping ' .. v.name)
|
|
|
|
|
end
|
2020-12-10 16:32:20 +00:00
|
|
|
end
|
2023-02-24 03:07:52 -05:00
|
|
|
|
2023-05-29 16:52:20 +02:00
|
|
|
lockfile = vim.fn.system('jq --sort-keys', vim.json.encode(lockfile))
|
|
|
|
|
util.write_file(filename, lockfile)
|