mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 11:06:54 -04:00
ci: remove update-lockfile shell script
This commit is contained in:
parent
cde679e435
commit
9c0a99819c
15 changed files with 84 additions and 103 deletions
|
|
@ -93,17 +93,20 @@ local ok, result = pcall(do_check)
|
|||
local allowed_to_fail = vim.split(vim.env.ALLOWED_INSTALLATION_FAILURES or '', ',', true)
|
||||
|
||||
for k, v in pairs(require('nvim-treesitter.parsers').configs) do
|
||||
if #vim.api.nvim_get_runtime_file('parser/' .. k .. '.*', false) == 0 then
|
||||
-- On CI all parsers that can be installed from C files should be installed
|
||||
if
|
||||
vim.env.CI
|
||||
and not v.install_info.requires_generate_from_grammar
|
||||
and not vim.list_contains(allowed_to_fail, k)
|
||||
then
|
||||
io_print('Error: parser for ' .. k .. ' is not installed')
|
||||
vim.cmd('cq')
|
||||
else
|
||||
io_print('Warning: parser for ' .. k .. ' is not installed')
|
||||
if v.install_info then
|
||||
-- skip "query only" languages
|
||||
if #vim.api.nvim_get_runtime_file('parser/' .. k .. '.*', false) == 0 then
|
||||
-- On CI all parsers that can be installed from C files should be installed
|
||||
if
|
||||
vim.env.CI
|
||||
and not v.install_info.requires_generate_from_grammar
|
||||
and not vim.list_contains(allowed_to_fail, k)
|
||||
then
|
||||
io_print('Error: parser for ' .. k .. ' is not installed')
|
||||
vim.cmd('cq')
|
||||
else
|
||||
io_print('Warning: parser for ' .. k .. ' is not installed')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
15
scripts/install-parsers.lua
Executable file
15
scripts/install-parsers.lua
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env -S nvim -l
|
||||
|
||||
vim.opt.runtimepath:append('.')
|
||||
|
||||
-- needed on CI
|
||||
vim.fn.mkdir(vim.fn.stdpath('cache'), 'p')
|
||||
|
||||
local done = false
|
||||
require('nvim-treesitter.install').install('all', {}, function()
|
||||
done = true
|
||||
end)
|
||||
|
||||
vim.wait(6000000, function()
|
||||
return done
|
||||
end)
|
||||
|
|
@ -2,11 +2,12 @@ vim.opt.runtimepath:append('.')
|
|||
vim.cmd.runtime({ 'plugin/plenary.vim', bang = true })
|
||||
vim.cmd.runtime({ 'plugin/nvim-treesitter.lua', bang = true })
|
||||
vim.cmd.runtime({ 'plugin/query_predicates.lua', bang = true })
|
||||
vim.cmd.runtime({ 'plugin/filetypes.lua', bang = true })
|
||||
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
conf = 'hocon',
|
||||
cmm = 't32',
|
||||
hurl = 'hurl',
|
||||
ncl = 'nickel',
|
||||
tig = 'tiger',
|
||||
w = 'wing',
|
||||
|
|
@ -20,6 +21,6 @@ require('nvim-treesitter').setup()
|
|||
vim.api.nvim_create_autocmd('FileType', {
|
||||
callback = function(args)
|
||||
pcall(vim.treesitter.start)
|
||||
vim.bo[args.buffer].indentexpr = 'v:lua.require"nvim-treesitter".indentexpr()'
|
||||
vim.bo[args.buf].indentexpr = 'v:lua.require"nvim-treesitter".indentexpr()'
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Can be used as a pre-push hook
|
||||
# Just symlink this file to .git/hooks/pre-push
|
||||
|
||||
echo "Running linter..."
|
||||
luacheck .
|
||||
|
||||
echo "Checking formatting..."
|
||||
stylua --check .
|
||||
|
|
@ -4,7 +4,7 @@ HERE="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
|||
cd $HERE/..
|
||||
|
||||
run() {
|
||||
nvim --headless --noplugin -u scripts/minimal_init.lua \
|
||||
nvim --headless --noplugin -u scripts/minimal_init.lua \
|
||||
-c "PlenaryBustedDirectory $1 { minimal_init = './scripts/minimal_init.lua' }"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
#!/usr/bin/env -S nvim -l
|
||||
vim.opt.runtimepath:append('.')
|
||||
local util = require('nvim-treesitter.util')
|
||||
|
||||
-- Load previous lockfile
|
||||
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?
|
||||
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 {}
|
||||
vim.print('Skipping languages: ', skip_langs)
|
||||
|
||||
local sorted_parsers = {}
|
||||
local configs = require('nvim-treesitter.parsers').configs
|
||||
for k, v in pairs(configs) do
|
||||
for k, v in pairs(require('nvim-treesitter.parsers').configs) do
|
||||
table.insert(sorted_parsers, { name = k, parser = v })
|
||||
end
|
||||
table.sort(sorted_parsers, function(a, b)
|
||||
|
|
@ -42,7 +42,6 @@ for _, v in ipairs(sorted_parsers) do
|
|||
print('Skipping ' .. v.name)
|
||||
end
|
||||
end
|
||||
vim.print(lockfile)
|
||||
|
||||
-- write new lockfile
|
||||
require('nvim-treesitter.util').write_file(filename, vim.json.encode(lockfile))
|
||||
lockfile = vim.fn.system('jq --sort-keys', 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
|
||||
vim.opt.runtimepath:append('.')
|
||||
|
||||
local util = require('nvim-treesitter.util')
|
||||
local parsers = require('nvim-treesitter.parsers')
|
||||
---@class Parser
|
||||
---@field name string
|
||||
---@field parser ParserInfo
|
||||
|
||||
local parsers = require('nvim-treesitter.parsers').configs
|
||||
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 })
|
||||
end
|
||||
table.sort(sorted_parsers, function(a, b)
|
||||
return a.name < b.name
|
||||
end)
|
||||
|
||||
local tiers = require('nvim-treesitter.parsers').tiers
|
||||
|
||||
local generated_text = [[
|
||||
Language | Tier | Queries | CLI | NPM | Maintainer
|
||||
-------- |:----:|:-------:|:---:|:---:| ----------
|
||||
|
|
@ -38,7 +36,7 @@ for _, v in ipairs(sorted_parsers) do
|
|||
end
|
||||
|
||||
-- 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
|
||||
generated_text = generated_text
|
||||
|
|
@ -66,7 +64,7 @@ end
|
|||
generated_text = generated_text .. footnotes
|
||||
|
||||
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(
|
||||
readme_text,
|
||||
|
|
@ -74,7 +72,7 @@ local new_readme_text = string.gsub(
|
|||
'<!--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
|
||||
print(readme .. ' is up-to-date\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue