diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2023-06-12 09:54:30 -0600 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2025-05-12 18:43:40 +0200 |
| commit | 692b051b09935653befdb8f7ba8afdb640adf17b (patch) | |
| tree | 167162b6b129ae04f68c5735078521a72917c742 /scripts/write-lockfile.lua | |
| parent | feat(c-family): inherit injections (diff) | |
| download | nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2 nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip | |
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'scripts/write-lockfile.lua')
| -rwxr-xr-x | scripts/write-lockfile.lua | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/scripts/write-lockfile.lua b/scripts/write-lockfile.lua index 7a7606c51..a264af83c 100755 --- a/scripts/write-lockfile.lua +++ b/scripts/write-lockfile.lua @@ -1,14 +1,52 @@ #!/usr/bin/env -S nvim -l +vim.opt.runtimepath:append('.') ----@type string|any[] -local skip_langs = vim.fn.getenv "SKIP_LOCKFILE_UPDATE_FOR_LANGS" +-- Load previous lockfile +local filename = require('nvim-treesitter.utils').get_package_path('lockfile.json') +local file = assert(io.open(filename, 'r')) +local lockfile = vim.json.decode(file:read('*a')) +file:close() -if skip_langs == vim.NIL then - skip_langs = {} -else - ---@diagnostic disable-next-line: param-type-mismatch - skip_langs = vim.fn.split(skip_langs, ",") +---@type string? +local skip_lang_string = os.getenv('SKIP_LOCKFILE_UPDATE_FOR_LANGS') +local skip_langs = skip_lang_string and vim.split(skip_lang_string, ',') or {} +vim.print('Skipping languages: ', skip_langs) + +local sorted_parsers = {} +local configs = require('nvim-treesitter.parsers').configs +for k, v in pairs(configs) do + 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 end +vim.print(lockfile) -require("nvim-treesitter.install").write_lockfile("verbose", skip_langs) -vim.cmd "q" +-- write new lockfile +file = assert(io.open(filename, 'w')) +file:write(vim.json.encode(lockfile)) +file:close() |
