feat: add Tact queries

This commit is contained in:
Novus Nota 2024-05-02 16:05:30 +02:00 committed by Lewis Russell
parent 4fe0a54e86
commit 2650e6431f
3 changed files with 285 additions and 0 deletions

View file

@ -72,6 +72,7 @@ Note: if you need support for Neovim 0.6.x please use the tag `compat/0.6`.
- [x] `solidity`
- [x] `svelte`
- [x] `swift`
- [x] `tact`
- [x] `tcl`
- [x] `teal`
- [x] `templ`

101
queries/tact/context.scm Normal file
View file

@ -0,0 +1,101 @@
; See: https://github.com/nvim-treesitter/nvim-treesitter-context/blob/master/CONTRIBUTING.md
; storage types
; -------------
(struct
body: (_
(_) @context.end)) @context
(message
body: (_
(_) @context.end)) @context
(contract
body: (_
(_) @context.end)) @context
(trait
body: (_
(_) @context.end)) @context
; functions
; ---------
(static_function
body: (_
(_) @context.end)) @context
(init_function
body: (_
(_) @context.end)) @context
(receive_function
body: (_
(_) @context.end)) @context
(external_function
body: (_
(_) @context.end)) @context
(bounced_function
body: (_
(_) @context.end)) @context
(function
body: (_
(_) @context.end)) @context
; statements
; ----------
(if_statement
consequence: (_
(_) @context.end)) @context
(else_clause
(_
(_) @context.end)) @context
(try_statement
body: (_
(_) @context.end)) @context
(catch_clause
body: (_
(_) @context.end)) @context
(while_statement
body: (_
(_) @context.end)) @context
(repeat_statement
body: (_
(_) @context.end)) @context
(do_until_statement
body: (_
(_) @context.end)) @context
(foreach_statement
body: (_
(_) @context.end)) @context
[
(return_statement)
(expression_statement)
] @context
; expressions
; -----------
(method_call_expression
arguments: (_
(_) @context.end)) @context
(static_call_expression
arguments: (_
(_) @context.end)) @context
(instance_expression
arguments: (_
(_) @context.end)) @context
(initOf
arguments: (_
(_) @context.end)) @context

183
test/test.tact Normal file
View file

@ -0,0 +1,183 @@
struct S {
// comment
}
message M {
// comment
}
trait C {
// comment
}
contract C {
init() {
// comment
}
receive() {
// comment
}
external() {
// comment
}
bounced(msg: bounced<M>) {
// comment
}
fun someFunction() {
// comment
}
}
fun statements() {
let a: map<Int, Int> = null;
if (true) {
// comment
} else {
// comment
}
try {
// comment
} catch (e) {
// comment
}
while (true) {
// comment
}
repeat (5) {
// comment
}
do {
// comment
} until (true);
foreach (k, v in a) {
// comment
}
// expression_statement
0
// comment
;
// return_statement
return
// comment
0;
// method_call_expression
0.toString(
// comment
);
// static_call_expression
ton(
"0.1" // comment
);
// instance_expression
S {
// comment
};
// initOf_expression
initOf C(
// comment
);
}