fix(zig): update queries for new zig treesitter parser

This commit is contained in:
Steven Arcangeli 2024-08-30 09:31:32 -07:00
parent 92f93f4e15
commit 491e2fc564
5 changed files with 58 additions and 35 deletions

View file

@ -31,4 +31,4 @@ scripts/nvim-typecheck-action:
git clone https://github.com/stevearc/nvim-typecheck-action scripts/nvim-typecheck-action
clean:
rm -rf scripts/nvim_doc_tools scripts/nvim-typecheck-action
rm -rf scripts/nvim_doc_tools scripts/nvim-typecheck-action .testenv

View file

@ -395,6 +395,15 @@ M.latex = {
-- This may not always be the case.
M.tsx = M.typescript
M.zig = {
postprocess = function(bufnr, item, match)
local node = assert(node_from_match(match, "symbol"))
if node:type() == "test_declaration" then
item.name = "test " .. item.name
end
end,
}
for _, lang in pairs(M) do
setmetatable(lang, { __index = default_methods })
end

View file

@ -1,27 +1,22 @@
(Decl
(VarDecl
variable_type_function: (IDENTIFIER) @name
(#set! "kind" "Struct")
(_
(_
(ContainerDecl
(ContainerDeclType
"struct") @symbol)))))
(Decl
(VarDecl
variable_type_function: (IDENTIFIER) @name
(#set! "kind" "Struct")
(_
(_
(ContainerDecl
(ContainerDeclType
"union") @symbol)))))
(FnProto
function: (IDENTIFIER) @name
(function_declaration
name: (identifier) @name
(#set! "kind" "Function")) @symbol
(TestDecl
(STRINGLITERALSINGLE) @name
(variable_declaration
(identifier) @name
(struct_declaration)
(#set! "kind" "Struct")) @symbol
(variable_declaration
(identifier) @name
(union_declaration)
(#set! "kind" "Struct")) @symbol
(test_declaration
(string
(string_content) @name)
(#set! "kind" "Function")) @symbol
(test_declaration
(identifier) @name
(#set! "kind" "Function")) @symbol

View file

@ -1,8 +1,8 @@
[
{
"col": 0,
"end_col": 16,
"end_lnum": 1,
"end_col": 1,
"end_lnum": 3,
"kind": "Function",
"level": 0,
"lnum": 1,
@ -15,9 +15,9 @@
}
},
{
"col": 17,
"end_col": 23,
"end_lnum": 5,
"col": 0,
"end_col": 2,
"end_lnum": 7,
"kind": "Struct",
"level": 0,
"lnum": 5,
@ -30,8 +30,8 @@
}
},
{
"col": 22,
"end_col": 33,
"col": 0,
"end_col": 55,
"end_lnum": 9,
"kind": "Struct",
"level": 0,
@ -51,12 +51,27 @@
"kind": "Function",
"level": 0,
"lnum": 11,
"name": "\"my test\"",
"name": "test my test",
"selection_range": {
"col": 5,
"end_col": 14,
"col": 6,
"end_col": 13,
"end_lnum": 11,
"lnum": 11
}
},
{
"col": 0,
"end_col": 1,
"end_lnum": 17,
"kind": "Function",
"level": 0,
"lnum": 15,
"name": "test ident_test",
"selection_range": {
"col": 5,
"end_col": 15,
"end_lnum": 15,
"lnum": 15
}
}
]

View file

@ -11,3 +11,7 @@ const MyTaggedUnion = union(enum) { choice1, choice2 };
test "my test" {
myFunc();
}
test ident_test {
myFunc();
}