mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-19 11:50:09 -04:00
ci: remove update-lockfile shell script
This commit is contained in:
parent
73ddd80069
commit
7681249bbd
4 changed files with 13 additions and 39 deletions
5
.github/workflows/update-lockfile.yml
vendored
5
.github/workflows/update-lockfile.yml
vendored
|
|
@ -28,10 +28,7 @@ jobs:
|
||||||
SKIP_LOCKFILE_UPDATE_FOR_LANGS: ""
|
SKIP_LOCKFILE_UPDATE_FOR_LANGS: ""
|
||||||
run: |
|
run: |
|
||||||
cp lockfile.json /tmp/old_lockfile.json
|
cp lockfile.json /tmp/old_lockfile.json
|
||||||
nvim -l scripts/write-lockfile.lua
|
nvim -l ./scripts/update-lockfile.lua
|
||||||
# Pretty print
|
|
||||||
cp lockfile.json /tmp/lockfile.json
|
|
||||||
cat /tmp/lockfile.json | jq --sort-keys > lockfile.json
|
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
run: |
|
run: |
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
#!/usr/bin/env -S nvim -l
|
#!/usr/bin/env -S nvim -l
|
||||||
vim.opt.runtimepath:append('.')
|
vim.opt.runtimepath:append('.')
|
||||||
|
local util = require('nvim-treesitter.util')
|
||||||
|
|
||||||
-- Load previous lockfile
|
-- Load previous lockfile
|
||||||
local filename = require('nvim-treesitter.install').get_package_path('lockfile.json')
|
local filename = require('nvim-treesitter.install').get_package_path('lockfile.json')
|
||||||
local lockfile = vim.json.decode(require('nvim-treesitter.util').read_file(filename))
|
local lockfile = vim.json.decode(util.read_file(filename))
|
||||||
|
|
||||||
---@type string?
|
---@type string?
|
||||||
local skip_lang_string = os.getenv('SKIP_LOCKFILE_UPDATE_FOR_LANGS')
|
local skip_lang_string = os.getenv('LOCKFILE_SKIP')
|
||||||
local skip_langs = skip_lang_string and vim.split(skip_lang_string, ',') or {}
|
local skip_langs = skip_lang_string and vim.split(skip_lang_string, ',') or {}
|
||||||
vim.print('Skipping languages: ', skip_langs)
|
vim.print('Skipping languages: ', skip_langs)
|
||||||
|
|
||||||
local sorted_parsers = {}
|
local sorted_parsers = {}
|
||||||
local configs = require('nvim-treesitter.parsers').configs
|
for k, v in pairs(require('nvim-treesitter.parsers').configs) do
|
||||||
for k, v in pairs(configs) do
|
|
||||||
table.insert(sorted_parsers, { name = k, parser = v })
|
table.insert(sorted_parsers, { name = k, parser = v })
|
||||||
end
|
end
|
||||||
table.sort(sorted_parsers, function(a, b)
|
table.sort(sorted_parsers, function(a, b)
|
||||||
|
|
@ -42,7 +42,6 @@ for _, v in ipairs(sorted_parsers) do
|
||||||
print('Skipping ' .. v.name)
|
print('Skipping ' .. v.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vim.print(lockfile)
|
|
||||||
|
|
||||||
-- write new lockfile
|
lockfile = vim.fn.system('jq --sort-keys', vim.json.encode(lockfile))
|
||||||
require('nvim-treesitter.util').write_file(filename, vim.json.encode(lockfile))
|
util.write_file(filename, lockfile)
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
make_ignored() {
|
|
||||||
if [ -n "$1" ]
|
|
||||||
then
|
|
||||||
while read -r lang; do
|
|
||||||
if [ "$lang" != "$1" ]
|
|
||||||
then
|
|
||||||
printf "%s," "$lang"
|
|
||||||
fi
|
|
||||||
done < <(jq 'keys|@sh' -c lockfile.json)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
TO_IGNORE=$(make_ignored $1)
|
|
||||||
|
|
||||||
SKIP_LOCKFILE_UPDATE_FOR_LANGS="$TO_IGNORE" nvim -l ./scripts/write-lockfile.lua
|
|
||||||
# Pretty print
|
|
||||||
cp lockfile.json /tmp/lockfile.json
|
|
||||||
cat /tmp/lockfile.json | jq --sort-keys > lockfile.json
|
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
#!/usr/bin/env -S nvim -l
|
#!/usr/bin/env -S nvim -l
|
||||||
vim.opt.runtimepath:append('.')
|
vim.opt.runtimepath:append('.')
|
||||||
|
local util = require('nvim-treesitter.util')
|
||||||
|
local parsers = require('nvim-treesitter.parsers')
|
||||||
---@class Parser
|
---@class Parser
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field parser ParserInfo
|
---@field parser ParserInfo
|
||||||
|
|
||||||
local parsers = require('nvim-treesitter.parsers').configs
|
|
||||||
local sorted_parsers = {}
|
local sorted_parsers = {}
|
||||||
for k, v in pairs(parsers) do
|
for k, v in pairs(parsers.configs) do
|
||||||
table.insert(sorted_parsers, { name = k, parser = v })
|
table.insert(sorted_parsers, { name = k, parser = v })
|
||||||
end
|
end
|
||||||
table.sort(sorted_parsers, function(a, b)
|
table.sort(sorted_parsers, function(a, b)
|
||||||
return a.name < b.name
|
return a.name < b.name
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local tiers = require('nvim-treesitter.parsers').tiers
|
|
||||||
|
|
||||||
local generated_text = [[
|
local generated_text = [[
|
||||||
Language | Tier | Queries | CLI | NPM | Maintainer
|
Language | Tier | Queries | CLI | NPM | Maintainer
|
||||||
-------- |:----:|:-------:|:---:|:---:| ----------
|
-------- |:----:|:-------:|:---:|:---:| ----------
|
||||||
|
|
@ -38,7 +36,7 @@ for _, v in ipairs(sorted_parsers) do
|
||||||
end
|
end
|
||||||
|
|
||||||
-- tier
|
-- tier
|
||||||
generated_text = generated_text .. (p.tier and tiers[p.tier] or '') .. ' | '
|
generated_text = generated_text .. (p.tier and parsers.tiers[p.tier] or '') .. ' | '
|
||||||
|
|
||||||
-- queries
|
-- queries
|
||||||
generated_text = generated_text
|
generated_text = generated_text
|
||||||
|
|
@ -66,7 +64,7 @@ end
|
||||||
generated_text = generated_text .. footnotes
|
generated_text = generated_text .. footnotes
|
||||||
|
|
||||||
local readme = 'SUPPORTED_LANGUAGES.md'
|
local readme = 'SUPPORTED_LANGUAGES.md'
|
||||||
local readme_text = require('nvim-treesitter.util').read_file(readme)
|
local readme_text = util.read_file(readme)
|
||||||
|
|
||||||
local new_readme_text = string.gsub(
|
local new_readme_text = string.gsub(
|
||||||
readme_text,
|
readme_text,
|
||||||
|
|
@ -74,7 +72,7 @@ local new_readme_text = string.gsub(
|
||||||
'<!--parserinfo-->\n' .. generated_text .. '<!--parserinfo-->'
|
'<!--parserinfo-->\n' .. generated_text .. '<!--parserinfo-->'
|
||||||
)
|
)
|
||||||
|
|
||||||
require('nvim-treesitter.util').write_file(readme, new_readme_text)
|
util.write_file(readme, new_readme_text)
|
||||||
|
|
||||||
if string.find(readme_text, generated_text, 1, true) then
|
if string.find(readme_text, generated_text, 1, true) then
|
||||||
print(readme .. ' is up-to-date\n')
|
print(readme .. ' is up-to-date\n')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue