Skip to content

Commit

Permalink
ci: install parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Jun 27, 2024
1 parent 2e0b35c commit 4ebc6b8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ jobs:
- name: Download nvim-test
run: make nvim-test

- name: Install parsers
run: make parsers NEOVIM_VERSION=$NEOVIM_VERSION

- name: Run Test
run: make test NEOVIM_VERSION=$NEOVIM_VERSION
3 changes: 3 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
- name: Download nvim-test
run: make nvim-test

- name: Install parsers
run: make parsers NEOVIM_VERSION=$NEOVIM_VERSION

- name: Run Test
run: make test NVIM_TS_SHA=$NVIM_TS_SHA

Expand Down
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ nvim-treesitter:
nvim-test:
git clone https://github.com/lewis6991/nvim-test
nvim-test/bin/nvim-test --init
--runner_version $(NEOVIM_VERSION) \
--target_version $(NEOVIM_VERSION)

.PHONY: test
test: nvim-test nvim-treesitter
Expand All @@ -25,5 +27,10 @@ test: nvim-test nvim-treesitter
--filter=$(FILTER) \
--verbose

.PHONY: parsers
parsers: nvim-test
$(XDG_DATA_HOME)/nvim-test/nvim-test-$(NEOVIM_VERSION)/bin/nvim \
--clean -u NONE -c 'source install_parsers.lua'

lint:
luacheck lua
33 changes: 33 additions & 0 deletions install_parsers.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

local function get_langs()
local f = assert(io.open('README.md', 'r'))
local readme_langs = {} --- @type table<string,true>
for l in f:lines() do
--- @type string?
local lang = l:match('%- %[x%] `([^`]+)`')
if lang then
readme_langs[lang] = true
end
end
f:close()

f = assert(io.open('nvim-treesitter/lockfile.json', 'r'))
local txt = f:read('*a')
local j = vim.json.decode(txt)

local langs = {} --- @type string[]
for k in pairs(j) do
if readme_langs[k] then
langs[#langs+1] = k
readme_langs[k] = nil
end
end
print('Invalid languages:', table.concat(vim.tbl_keys(readme_langs), ', '))
return langs
end

vim.cmd [[set runtimepath+=.,./nvim-treesitter]]
require'nvim-treesitter.install'.prefer_git = false
require("nvim-treesitter").setup()
require'nvim-treesitter.install'.ensure_installed_sync(get_langs())
vim.cmd.quit()

0 comments on commit 4ebc6b8

Please sign in to comment.