From 4ebc6b8e96b22c9473e135f459dca3f1a3b510d1 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 27 Jun 2024 17:30:24 +0100 Subject: [PATCH] ci: install parsers --- .github/workflows/ci.yml | 3 +++ .github/workflows/nightly.yml | 3 +++ Makefile | 7 +++++++ install_parsers.lua | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 install_parsers.lua diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc9c578..3a3a1e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 064b0f3..167a356 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -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 diff --git a/Makefile b/Makefile index aa8cce3..767bec7 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 diff --git a/install_parsers.lua b/install_parsers.lua new file mode 100644 index 0000000..a85349b --- /dev/null +++ b/install_parsers.lua @@ -0,0 +1,33 @@ + +local function get_langs() + local f = assert(io.open('README.md', 'r')) + local readme_langs = {} --- @type table + 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()