mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
feat(zig): basic treesitter support for zig. (#359)
* Add basic support for navigating zig files. * Fix struct start position. * Add test and tagged unions. * Add test.
This commit is contained in:
parent
24ebacab58
commit
5961a1afc0
3 changed files with 107 additions and 0 deletions
32
queries/zig/aerial.scm
Normal file
32
queries/zig/aerial.scm
Normal file
|
@ -0,0 +1,32 @@
|
|||
(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
|
||||
(#set! "kind" "Function")
|
||||
) @symbol
|
||||
|
||||
|
||||
(TestDecl
|
||||
(STRINGLITERALSINGLE) @name
|
||||
(#set! "kind" "Function")
|
||||
) @symbol
|
62
tests/symbols/zig_test.json
Normal file
62
tests/symbols/zig_test.json
Normal file
|
@ -0,0 +1,62 @@
|
|||
[
|
||||
{
|
||||
"col": 0,
|
||||
"end_col": 16,
|
||||
"end_lnum": 1,
|
||||
"kind": "Function",
|
||||
"level": 0,
|
||||
"lnum": 1,
|
||||
"name": "myFunc",
|
||||
"selection_range": {
|
||||
"col": 3,
|
||||
"end_col": 9,
|
||||
"end_lnum": 1,
|
||||
"lnum": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"col": 17,
|
||||
"end_col": 23,
|
||||
"end_lnum": 5,
|
||||
"kind": "Struct",
|
||||
"level": 0,
|
||||
"lnum": 5,
|
||||
"name": "MyStruct",
|
||||
"selection_range": {
|
||||
"col": 6,
|
||||
"end_col": 14,
|
||||
"end_lnum": 5,
|
||||
"lnum": 5
|
||||
}
|
||||
},
|
||||
{
|
||||
"col": 22,
|
||||
"end_col": 33,
|
||||
"end_lnum": 9,
|
||||
"kind": "Struct",
|
||||
"level": 0,
|
||||
"lnum": 9,
|
||||
"name": "MyTaggedUnion",
|
||||
"selection_range": {
|
||||
"col": 6,
|
||||
"end_col": 19,
|
||||
"end_lnum": 9,
|
||||
"lnum": 9
|
||||
}
|
||||
},
|
||||
{
|
||||
"col": 0,
|
||||
"end_col": 1,
|
||||
"end_lnum": 13,
|
||||
"kind": "Function",
|
||||
"level": 0,
|
||||
"lnum": 11,
|
||||
"name": "\"my test\"",
|
||||
"selection_range": {
|
||||
"col": 5,
|
||||
"end_col": 14,
|
||||
"end_lnum": 11,
|
||||
"lnum": 11
|
||||
}
|
||||
}
|
||||
]
|
13
tests/treesitter/zig_test.zig
Normal file
13
tests/treesitter/zig_test.zig
Normal file
|
@ -0,0 +1,13 @@
|
|||
fn myFunc() bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
const MyStruct = struct {
|
||||
is_true: bool,
|
||||
};
|
||||
|
||||
const MyTaggedUnion = union(enum) { choice1, choice2 };
|
||||
|
||||
test "my test" {
|
||||
myFunc();
|
||||
}
|
Loading…
Reference in a new issue