Skip to content

Commit caeaa01

Browse files
committed
ci!: update nvim-treesitter to main
Since nvim-treesitter@main only supports Nvim 0.11, testing for Nvim 0.9.* and 0.10.* have been dropped.
1 parent 33b3f5a commit caeaa01

File tree

11 files changed

+101
-164
lines changed

11 files changed

+101
-164
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ jobs:
5151
fail-fast: false
5252
matrix:
5353
neovim_version:
54-
- 'v0.9.5'
55-
- 'v0.10.2'
54+
- 'v0.11.1'
5655

5756
env:
5857
NVIM_TEST_VERSION: ${{ matrix.neovim_version }}

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export XDG_DATA_HOME ?= $(HOME)/.data
66
# nvim-treesitter
77
# ------------------------------------------------------------------------------
88

9-
NVIM_TS_SHA ?= 2cade9e
9+
NVIM_TS_SHA ?= 61b0a05e
1010
NVIM_TS := deps/nvim-treesitter
1111

1212
.PHONY: nvim-treesitter
@@ -24,8 +24,8 @@ $(NVIM_TS):
2424

2525
FILTER=.*
2626

27-
export NVIM_TEST_VERSION ?= v0.10.2
28-
export NVIM_RUNNER_VERSION ?= v0.10.2
27+
export NVIM_TEST_VERSION ?= v0.11.1
28+
export NVIM_RUNNER_VERSION ?= v0.11.1
2929

3030
NVIM_TEST := deps/nvim-test
3131
NVIM_TEST_REV = v1.1.0
@@ -52,7 +52,7 @@ test: $(NVIM_TEST) $(NVIM_TS)
5252
.PHONY: parsers
5353
parsers: $(NVIM_TEST) $(NVIM_TS)
5454
$(XDG_DATA_HOME)/nvim-test/nvim-runner-$(NVIM_RUNNER_VERSION)/bin/nvim \
55-
--clean -u NONE -c 'source install_parsers.lua'
55+
-l test/helpers.lua install
5656

5757
lint:
5858
luacheck lua

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Note: support for specific languages is strictly community maintained and can br
2222
<details>
2323
<summary>Supported (click to expand)</summary
2424
25-
- [x] `org`
2625
- [x] `ada`
2726
- [x] `apex`
2827
- [x] `bash`
@@ -69,7 +68,6 @@ Note: support for specific languages is strictly community maintained and can br
6968
- [x] `matlab`
7069
- [x] `nim`
7170
- [x] `nix`
72-
- [x] `norg`
7371
- [x] `nu`
7472
- [x] `objdump`
7573
- [x] `ocaml`
@@ -127,8 +125,11 @@ Note: support for specific languages is strictly community maintained and can br
127125
- [ ] `bibtex`
128126
- [ ] `bicep`
129127
- [ ] `bitbake`
128+
- [ ] `blade`
130129
- [ ] `blueprint`
131130
- [ ] `bp`
131+
- [ ] `brightscript`
132+
- [ ] `caddy`
132133
- [ ] `cairo`
133134
- [ ] `chatito`
134135
- [ ] `circom`
@@ -149,6 +150,7 @@ Note: support for specific languages is strictly community maintained and can br
149150
- [ ] `dtd`
150151
- [ ] `earthfile`
151152
- [ ] `ebnf`
153+
- [ ] `ecma`
152154
- [ ] `editorconfig`
153155
- [ ] `eds`
154156
- [ ] `eex`
@@ -199,6 +201,7 @@ Note: support for specific languages is strictly community maintained and can br
199201
- [ ] `hlsplaylist`
200202
- [ ] `hocon`
201203
- [ ] `hoon`
204+
- [ ] `html_tags`
202205
- [ ] `htmldjango`
203206
- [ ] `http`
204207
- [ ] `hurl`
@@ -208,13 +211,16 @@ Note: support for specific languages is strictly community maintained and can br
208211
- [ ] `inko`
209212
- [ ] `ipkg`
210213
- [ ] `ispc`
214+
- [ ] `javadoc`
211215
- [ ] `jinja`
212216
- [ ] `jinja_inline`
213217
- [ ] `jq`
214218
- [ ] `jsdoc`
215219
- [ ] `json5`
216220
- [ ] `jsonc`
221+
- [ ] `jsx`
217222
- [ ] `just`
223+
- [ ] `kcl`
218224
- [ ] `kconfig`
219225
- [ ] `kotlin`
220226
- [ ] `koto`
@@ -312,6 +318,7 @@ Note: support for specific languages is strictly community maintained and can br
312318
- [ ] `systemtap`
313319
- [ ] `t32`
314320
- [ ] `tablegen`
321+
- [ ] `tera`
315322
- [ ] `textproto`
316323
- [ ] `thrift`
317324
- [ ] `tiger`

install_parsers.lua

Lines changed: 0 additions & 33 deletions
This file was deleted.

queries/norg/context.scm

Lines changed: 0 additions & 7 deletions
This file was deleted.

queries/org/context.scm

Lines changed: 0 additions & 3 deletions
This file was deleted.

queries/tcl/context.scm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
(procedure) @context
22
(while) @context
3-
(conditional) @context
3+
(if) @context
4+
(else) @context
5+
(elseif) @context
46
(command) @context

test/contexts_spec.lua

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
local helpers = require('nvim-test.helpers')
2-
local clear = helpers.clear
32
local exec_lua = helpers.exec_lua
43
local cmd = helpers.api.nvim_command
54
local feed = helpers.feed
@@ -71,7 +70,7 @@ local function install_langs_for_file(filename, root_lang)
7170
if seen_langs[current_lang] then
7271
goto continue
7372
end
74-
install_langs(current_lang)
73+
exec_lua(install_langs, current_lang)
7574

7675
-- Query for injections in the current language, and queue them for installation.
7776
--- @diagnostic disable-next-line: redefined-local Not actually redefining locals
@@ -121,28 +120,24 @@ end
121120

122121
local lang_to_test_files = {} --- @type table<string,string[]>
123122
setup(function()
124-
clear()
125-
cmd([[set runtimepath+=.,./deps/nvim-treesitter]])
123+
helpers.clear()
124+
exec_lua(tc_helpers.setup)
126125

127-
-- Required to load custom predicates
128-
exec_lua([[require'nvim-treesitter'.setup()]])
126+
exec_lua(install_langs, 'lua')
129127

130128
local test_files = fn.globpath('test/lang', '*', true, true) --- @type string[]
131129
for _, test_file in ipairs(test_files) do
132130
cmd('edit ' .. test_file)
133131
local bufnr = api.nvim_get_current_buf()
134132
--- @type string
135-
local treesitter_lang = exec_lua(
136-
[[
137-
local ok, parser = pcall(vim.treesitter.get_parser, ...)
138-
if not ok then
139-
return nil
140-
end
141-
return parser:lang()
142-
]],
143-
bufnr
144-
)
145-
if treesitter_lang ~= vim.NIL and treesitter_lang ~= '' then
133+
local treesitter_lang = exec_lua(function(...)
134+
local ok, parser = pcall(vim.treesitter.get_parser, ...)
135+
if not ok then
136+
return nil
137+
end
138+
return parser:lang()
139+
end, bufnr)
140+
if treesitter_lang ~= nil and treesitter_lang ~= '' then
146141
if not lang_to_test_files[treesitter_lang] then
147142
lang_to_test_files[treesitter_lang] = {}
148143
end

test/helpers.lua

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
1-
local helpers = require('nvim-test.helpers')
2-
local exec_lua = helpers.exec_lua
3-
41
local M = {}
52

63
function M.install_langs(langs)
74
if type(langs) == 'string' then
85
langs = { langs }
96
end
10-
exec_lua(
11-
[[
12-
local langs = ...
13-
require'nvim-treesitter.configs'.setup {
14-
ensure_installed = langs,
15-
sync_install = true,
16-
}
17-
18-
-- Clear the message "<lang> has been installed".
19-
print(' ')
20-
]],
21-
langs
22-
)
7+
require('nvim-treesitter').install(langs):wait()
8+
-- Dirty hack to clear ext_messages
9+
vim.cmd.normal(':<esc>')
2310
end
2411

2512
local langs --- @type string[]?
@@ -41,9 +28,10 @@ function M.get_langs()
4128
end
4229
f:close()
4330

44-
f = assert(io.open('deps/nvim-treesitter/lockfile.json', 'r'))
31+
---@type table<string, table>
32+
local parsers = require('deps/nvim-treesitter/lua/nvim-treesitter/parsers')
4533

46-
for k in vim.spairs(vim.json.decode(f:read('*a'))) do
34+
for k in vim.spairs(parsers) do
4735
langs[#langs + 1] = k
4836
if readme_langs[k] then
4937
readme_langs[k] = nil
@@ -55,4 +43,25 @@ function M.get_langs()
5543
return langs
5644
end
5745

46+
function M.setup()
47+
-- Do not pull in parsers from /usr/local/share/ as they may
48+
-- be the wrong ABI
49+
vim.opt.runtimepath = {
50+
vim.env.VIMRUNTIME,
51+
'.',
52+
'./deps/nvim-treesitter',
53+
}
54+
require('nvim-treesitter').setup({
55+
install_dir = vim.fs.joinpath('deps', 'nvim-treesitter-data'),
56+
})
57+
58+
vim.env.XDG_CACHE_HOME = 'scratch/cache'
59+
vim.opt.packpath = ''
60+
end
61+
62+
if arg[0] == 'test/helpers.lua' and arg[1] == 'install' then
63+
M.setup()
64+
M.install_langs(M.get_langs())
65+
end
66+
5867
return M

test/queries_spec.lua

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
--- Test the query for each language is valid and update the README.
22
local helpers = require('nvim-test.helpers')
3-
local clear = helpers.clear
43
local exec_lua = helpers.exec_lua
5-
local cmd = helpers.api.nvim_command
64

75
local tc_helpers = require('test.helpers')
86
local install_langs = tc_helpers.install_langs
@@ -12,11 +10,8 @@ describe('query:', function()
1210
local readme_lines = {} --- @type string[]
1311

1412
setup(function()
15-
clear()
16-
cmd([[set runtimepath+=.,./deps/nvim-treesitter]])
17-
-- Required to load custom predicates
18-
exec_lua([[require'nvim-treesitter'.setup()]])
19-
cmd([[let $XDG_CACHE_HOME='scratch/cache']])
13+
helpers.clear()
14+
exec_lua(tc_helpers.setup)
2015

2116
local f = assert(io.open('README.md', 'r'))
2217
for l in f:lines() do
@@ -56,7 +51,7 @@ describe('query:', function()
5651
table.insert(readme_lines, last_lang_index, (' - [ ] `%s`'):format(lang))
5752
pending('no queries/' .. lang .. '/context.scm')
5853
else
59-
install_langs(lang)
54+
exec_lua(install_langs, lang)
6055
local ok = exec_lua([[return pcall(vim.treesitter.query.get, ...)]], lang, 'context')
6156
table.insert(
6257
readme_lines,

0 commit comments

Comments
 (0)