refactor: rewrite installation using jobs and async

Replace sync variants with callback support
This commit is contained in:
Lewis Russell
2023-05-22 14:35:25 +01:00
committed by Christian Clason
parent 5aa2984a02
commit cde679e435
15 changed files with 951 additions and 709 deletions

View File

@@ -65,9 +65,8 @@ for _, v in ipairs(sorted_parsers) do
end
generated_text = generated_text .. footnotes
local readme = assert(io.open('SUPPORTED_LANGUAGES.md', 'r'))
local readme_text = readme:read('*a')
readme:close()
local readme = 'SUPPORTED_LANGUAGES.md'
local readme_text = require('nvim-treesitter.util').read_file(readme)
local new_readme_text = string.gsub(
readme_text,
@@ -75,12 +74,10 @@ local new_readme_text = string.gsub(
'<!--parserinfo-->\n' .. generated_text .. '<!--parserinfo-->'
)
readme = assert(io.open('SUPPORTED_LANGUAGES.md', 'w'))
readme:write(new_readme_text)
readme:close()
require('nvim-treesitter.util').write_file(readme, new_readme_text)
if string.find(readme_text, generated_text, 1, true) then
print('README.md is up-to-date\n')
print(readme .. ' is up-to-date\n')
else
print('New README.md was written\n')
print('New ' .. readme .. ' was written\n')
end

View File

@@ -2,10 +2,8 @@
vim.opt.runtimepath:append('.')
-- Load previous lockfile
local filename = require('nvim-treesitter.shell_cmds').get_package_path('lockfile.json')
local file = assert(io.open(filename, 'r'))
local lockfile = vim.json.decode(file:read('*a'))
file:close()
local filename = require('nvim-treesitter.install').get_package_path('lockfile.json')
local lockfile = vim.json.decode(require('nvim-treesitter.util').read_file(filename))
---@type string?
local skip_lang_string = os.getenv('SKIP_LOCKFILE_UPDATE_FOR_LANGS')
@@ -47,6 +45,4 @@ end
vim.print(lockfile)
-- write new lockfile
file = assert(io.open(filename, 'w'))
file:write(vim.json.encode(lockfile))
file:close()
require('nvim-treesitter.util').write_file(filename, vim.json.encode(lockfile))