Skip to content

Cannot get Treesitter to detect Zig tests #294

Answered by lawrence-laz
lawrence-laz asked this question in Q&A
Discussion options

You must be logged in to vote

Turns out I was missing capture groups:

local async = require("neotest.async")
local lib = require("neotest.lib")
local ts = lib.treesitter

async.run(function()
	local parse_queries = [[
      ;;query
      (TestDecl
      	(STRINGLITERALSINGLE) @test.name
      ) @test.definition
    ]]
	local tree = ts.parse_positions("main.zig", parse_queries)
	vim.print(tree:to_list())
end)

now returns:

{ {
    id = "main.zig",
    name = "main.zig",
    path = "main.zig",
    range = { 0, 0, 24, 0 },
    type = "file"
  }, { {
      id = 'main.zig::"my test"',
      name = '"my test"',
      path = "main.zig",
      range = { 15, 0, 18, 1 },
      type = "test"
    } }, { {
      id = 'main.zig::"my…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lawrence-laz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant