Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ jobs:
fail-fast: false
matrix:
neovim_version:
- 'v0.9.5'
- 'v0.10.2'
- 'v0.11.1'

env:
NVIM_TEST_VERSION: ${{ matrix.neovim_version }}
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export XDG_DATA_HOME ?= $(HOME)/.data
# nvim-treesitter
# ------------------------------------------------------------------------------

NVIM_TS_SHA ?= 2cade9e
NVIM_TS_SHA ?= 61b0a05e
NVIM_TS := deps/nvim-treesitter

.PHONY: nvim-treesitter
Expand All @@ -24,8 +24,8 @@ $(NVIM_TS):

FILTER=.*

export NVIM_TEST_VERSION ?= v0.10.2
export NVIM_RUNNER_VERSION ?= v0.10.2
export NVIM_TEST_VERSION ?= v0.11.1
export NVIM_RUNNER_VERSION ?= v0.11.1

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

lint:
luacheck lua
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Note: support for specific languages is strictly community maintained and can br
<details>
<summary>Supported (click to expand)</summary

- [x] `org`
- [x] `ada`
- [x] `apex`
- [x] `bash`
Expand Down Expand Up @@ -69,7 +68,6 @@ Note: support for specific languages is strictly community maintained and can br
- [x] `matlab`
- [x] `nim`
- [x] `nix`
- [x] `norg`
- [x] `nu`
- [x] `objdump`
- [x] `ocaml`
Expand Down Expand Up @@ -127,8 +125,11 @@ Note: support for specific languages is strictly community maintained and can br
- [ ] `bibtex`
- [ ] `bicep`
- [ ] `bitbake`
- [ ] `blade`
- [ ] `blueprint`
- [ ] `bp`
- [ ] `brightscript`
- [ ] `caddy`
- [ ] `cairo`
- [ ] `chatito`
- [ ] `circom`
Expand All @@ -149,6 +150,7 @@ Note: support for specific languages is strictly community maintained and can br
- [ ] `dtd`
- [ ] `earthfile`
- [ ] `ebnf`
- [ ] `ecma`
- [ ] `editorconfig`
- [ ] `eds`
- [ ] `eex`
Expand Down Expand Up @@ -199,6 +201,7 @@ Note: support for specific languages is strictly community maintained and can br
- [ ] `hlsplaylist`
- [ ] `hocon`
- [ ] `hoon`
- [ ] `html_tags`
- [ ] `htmldjango`
- [ ] `http`
- [ ] `hurl`
Expand All @@ -208,13 +211,16 @@ Note: support for specific languages is strictly community maintained and can br
- [ ] `inko`
- [ ] `ipkg`
- [ ] `ispc`
- [ ] `javadoc`
- [ ] `jinja`
- [ ] `jinja_inline`
- [ ] `jq`
- [ ] `jsdoc`
- [ ] `json5`
- [ ] `jsonc`
- [ ] `jsx`
- [ ] `just`
- [ ] `kcl`
- [ ] `kconfig`
- [ ] `kotlin`
- [ ] `koto`
Expand Down Expand Up @@ -312,6 +318,7 @@ Note: support for specific languages is strictly community maintained and can br
- [ ] `systemtap`
- [ ] `t32`
- [ ] `tablegen`
- [ ] `tera`
- [ ] `textproto`
- [ ] `thrift`
- [ ] `tiger`
Expand Down
33 changes: 0 additions & 33 deletions install_parsers.lua

This file was deleted.

7 changes: 0 additions & 7 deletions queries/norg/context.scm

This file was deleted.

3 changes: 0 additions & 3 deletions queries/org/context.scm

This file was deleted.

4 changes: 3 additions & 1 deletion queries/tcl/context.scm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(procedure) @context
(while) @context
(conditional) @context
(if) @context
(else) @context
(elseif) @context
(command) @context
29 changes: 12 additions & 17 deletions test/contexts_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local helpers = require('nvim-test.helpers')
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local cmd = helpers.api.nvim_command
local feed = helpers.feed
Expand Down Expand Up @@ -71,7 +70,7 @@ local function install_langs_for_file(filename, root_lang)
if seen_langs[current_lang] then
goto continue
end
install_langs(current_lang)
exec_lua(install_langs, current_lang)

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

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

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

local test_files = fn.globpath('test/lang', '*', true, true) --- @type string[]
for _, test_file in ipairs(test_files) do
cmd('edit ' .. test_file)
local bufnr = api.nvim_get_current_buf()
--- @type string
local treesitter_lang = exec_lua(
[[
local ok, parser = pcall(vim.treesitter.get_parser, ...)
if not ok then
return nil
end
return parser:lang()
]],
bufnr
)
if treesitter_lang ~= vim.NIL and treesitter_lang ~= '' then
local treesitter_lang = exec_lua(function(...)
local ok, parser = pcall(vim.treesitter.get_parser, ...)
if not ok then
return nil
end
return parser:lang()
end, bufnr)
if treesitter_lang ~= nil and treesitter_lang ~= '' then
if not lang_to_test_files[treesitter_lang] then
lang_to_test_files[treesitter_lang] = {}
end
Expand Down
45 changes: 27 additions & 18 deletions test/helpers.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
local helpers = require('nvim-test.helpers')
local exec_lua = helpers.exec_lua

local M = {}

function M.install_langs(langs)
if type(langs) == 'string' then
langs = { langs }
end
exec_lua(
[[
local langs = ...
require'nvim-treesitter.configs'.setup {
ensure_installed = langs,
sync_install = true,
}

-- Clear the message "<lang> has been installed".
print(' ')
]],
langs
)
require('nvim-treesitter').install(langs):wait()
-- Dirty hack to clear ext_messages
vim.cmd.normal(':<esc>')
end

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

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

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

function M.setup()
-- Do not pull in parsers from /usr/local/share/ as they may
-- be the wrong ABI
vim.opt.runtimepath = {
vim.env.VIMRUNTIME,
'.',
'./deps/nvim-treesitter',
}
require('nvim-treesitter').setup({
install_dir = vim.fs.joinpath('deps', 'nvim-treesitter-data'),
})

vim.env.XDG_CACHE_HOME = 'scratch/cache'
vim.opt.packpath = ''
end

if arg[0] == 'test/helpers.lua' and arg[1] == 'install' then
M.setup()
M.install_langs(M.get_langs())
end

return M
11 changes: 3 additions & 8 deletions test/queries_spec.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
--- Test the query for each language is valid and update the README.
local helpers = require('nvim-test.helpers')
local clear = helpers.clear
local exec_lua = helpers.exec_lua
local cmd = helpers.api.nvim_command

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

setup(function()
clear()
cmd([[set runtimepath+=.,./deps/nvim-treesitter]])
-- Required to load custom predicates
exec_lua([[require'nvim-treesitter'.setup()]])
cmd([[let $XDG_CACHE_HOME='scratch/cache']])
helpers.clear()
exec_lua(tc_helpers.setup)

local f = assert(io.open('README.md', 'r'))
for l in f:lines() do
Expand Down Expand Up @@ -56,7 +51,7 @@ describe('query:', function()
table.insert(readme_lines, last_lang_index, (' - [ ] `%s`'):format(lang))
pending('no queries/' .. lang .. '/context.scm')
else
install_langs(lang)
exec_lua(install_langs, lang)
local ok = exec_lua([[return pcall(vim.treesitter.query.get, ...)]], lang, 'context')
table.insert(
readme_lines,
Expand Down
Loading
Loading