aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNovus Nota <68142933+novusnota@users.noreply.github.com>2024-05-03 18:42:51 +0200
committerGitHub <noreply@github.com>2024-05-03 18:42:51 +0200
commit440f177277e6049d665382a94ce1af602900b5c7 (patch)
tree377f43f63f54fbf74c4572826856b63c2a2ae94d
parentfeat(ecma) fold `array` (#6564) (diff)
downloadnvim-treesitter-440f177277e6049d665382a94ce1af602900b5c7.tar
nvim-treesitter-440f177277e6049d665382a94ce1af602900b5c7.tar.gz
nvim-treesitter-440f177277e6049d665382a94ce1af602900b5c7.tar.bz2
nvim-treesitter-440f177277e6049d665382a94ce1af602900b5c7.tar.lz
nvim-treesitter-440f177277e6049d665382a94ce1af602900b5c7.tar.xz
nvim-treesitter-440f177277e6049d665382a94ce1af602900b5c7.tar.zst
nvim-treesitter-440f177277e6049d665382a94ce1af602900b5c7.zip
feat: add support for Tact (#6554)
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/tact/folds.scm16
-rw-r--r--queries/tact/highlights.scm307
-rw-r--r--queries/tact/indents.scm50
-rw-r--r--queries/tact/injections.scm2
-rw-r--r--queries/tact/locals.scm72
8 files changed, 459 insertions, 0 deletions
diff --git a/README.md b/README.md
index 7a0bf9bf6..3cb08346a 100644
--- a/README.md
+++ b/README.md
@@ -407,6 +407,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [systemtap](https://github.com/ok-ryoko/tree-sitter-systemtap) (maintained by @ok-ryoko)
- [x] [t32](https://gitlab.com/xasc/tree-sitter-t32.git) (maintained by @xasc)
- [x] [tablegen](https://github.com/amaanq/tree-sitter-tablegen) (maintained by @amaanq)
+- [x] [tact](https://github.com/tact-lang/tree-sitter-tact) (maintained by @novusnota)
- [x] [tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) (maintained by @lewis6991)
- [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce)
- [x] [templ](https://github.com/vrischmann/tree-sitter-templ) (maintained by @vrischmann)
diff --git a/lockfile.json b/lockfile.json
index 410234f51..2e1150139 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -701,6 +701,9 @@
"tablegen": {
"revision": "6b7eb096621443627cc5e29c8c34ff1fde482cf3"
},
+ "tact": {
+ "revision": "83d5de4c0566ce4415c30cd4633e4ebb09a1d6b8"
+ },
"tcl": {
"revision": "8784024358c233efd0f3a6fd9e7a3c5852e628bc"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 20e65ff94..169ffea2d 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -2041,6 +2041,14 @@ list.tablegen = {
maintainers = { "@amaanq" },
}
+list.tact = {
+ install_info = {
+ url = "https://github.com/tact-lang/tree-sitter-tact",
+ files = { "src/parser.c" },
+ },
+ maintainers = { "@novusnota" },
+}
+
list.teal = {
install_info = {
url = "https://github.com/euclidianAce/tree-sitter-teal",
diff --git a/queries/tact/folds.scm b/queries/tact/folds.scm
new file mode 100644
index 000000000..8e286c340
--- /dev/null
+++ b/queries/tact/folds.scm
@@ -0,0 +1,16 @@
+[
+ ; import …
+ (import_statement)+
+ ; (…, …)
+ (parameter_list)
+ (argument_list)
+ ; {…, …}
+ (instance_argument_list)
+ ; {…; …}
+ (message_body)
+ (struct_body)
+ (contract_body)
+ (trait_body)
+ (function_body)
+ (block_statement)
+] @fold
diff --git a/queries/tact/highlights.scm b/queries/tact/highlights.scm
new file mode 100644
index 000000000..394463c65
--- /dev/null
+++ b/queries/tact/highlights.scm
@@ -0,0 +1,307 @@
+; variable
+; --------
+(identifier) @variable
+
+; variable.builtin
+; ----------------
+(self) @variable.builtin
+
+; variable.parameter
+; ------------------
+(parameter
+ name: (identifier) @variable.parameter)
+
+; punctuation.delimiter
+; ---------------------
+[
+ ";"
+ ","
+ "."
+ ":"
+ "?"
+] @punctuation.delimiter
+
+; punctuation.bracket
+; -------------------
+[
+ "("
+ ")"
+ "{"
+ "}"
+] @punctuation.bracket
+
+; operator
+; --------
+[
+ "-"
+ "-="
+ "+"
+ "+="
+ "*"
+ "*="
+ "/"
+ "/="
+ "%"
+ "%="
+ "="
+ "=="
+ "!"
+ "!="
+ "!!"
+ "<"
+ "<="
+ "<<"
+ ">"
+ ">="
+ ">>"
+ "&"
+ "|"
+ "^"
+ "&&"
+ "||"
+] @operator
+
+; constructor
+; -----------
+(instance_expression
+ name: (identifier) @constructor)
+
+(initOf
+ name: (identifier) @constructor)
+
+; type
+; ----
+(type_identifier) @type
+
+; type.builtin
+; ------------
+((identifier) @type.builtin
+ (#eq? @type.builtin "SendParameters"))
+
+(bounced_type
+ "bounced" @type.builtin
+ "<" @punctuation.bracket
+ ">" @punctuation.bracket)
+
+(map_type
+ "map" @type.builtin
+ "<" @punctuation.bracket
+ ">" @punctuation.bracket)
+
+((type_identifier) @type.builtin
+ (#any-of? @type.builtin "Address" "Bool" "Builder" "Cell" "Int" "Slice" "String" "StringBuilder"))
+
+(tlb_serialization
+ "as" @keyword
+ type: (identifier) @type.builtin
+ (#any-of? @type.builtin
+ "int8" "int16" "int32" "int64" "int128" "int256" "int257" "uint8" "uint16" "uint32" "uint64"
+ "uint128" "uint256" "coins" "remaining" "bytes32" "bytes64"))
+
+; string
+; ------
+(string) @string
+
+; string.escape
+; -------------
+(escape_sequence) @string.escape
+
+; string.special.path
+; -------------------
+(import_statement
+ library: (string) @string.special.path)
+
+; boolean
+; -------
+(boolean) @boolean
+
+; constant
+; --------
+(constant
+ name: (identifier) @constant)
+
+; constant.builtin
+; ----------------
+(null) @constant.builtin
+
+((identifier) @constant.builtin
+ (#any-of? @constant.builtin
+ "SendBounceIfActionFail" "SendPayGasSeparately" "SendIgnoreErrors" "SendDestroyIfZero"
+ "SendRemainingValue" "SendRemainingBalance" "ReserveExact" "ReserveAllExcept" "ReserveAtMost"
+ "ReserveAddOriginalBalance" "ReserveInvertSign" "ReserveBounceIfActionFail"))
+
+; property
+; --------
+(instance_argument
+ name: (identifier) @variable.member)
+
+(lvalue
+ (_)
+ (_) @variable.member)
+
+(field_access_expression
+ name: (identifier) @variable.member)
+
+(trait_body
+ (constant
+ name: (identifier) @variable.member))
+
+(contract_body
+ (constant
+ name: (identifier) @variable.member))
+
+(field
+ name: (identifier) @variable.member)
+
+; number
+; ------
+(integer) @number
+
+; keyword
+; -------
+[
+ "with"
+ "const"
+ "let"
+ ; "public" ; -- not used, but declared in grammar.ohm
+ ; "extend" ; -- not used, but declared in grammar.ohm
+] @keyword
+
+; keyword.type
+; ------------
+[
+ "contract"
+ "trait"
+ "struct"
+ "message"
+] @keyword.type
+
+; keyword.function
+; ----------------
+[
+ "fun"
+ "native"
+] @keyword.function
+
+; keyword.operator
+; ----------------
+"initOf" @keyword.operator
+
+; keyword.import
+; --------------
+"import" @keyword.import
+
+; keyword.modifier
+; ---------------
+[
+ "get"
+ "mutates"
+ "extends"
+ "virtual"
+ "override"
+ "inline"
+ "abstract"
+] @keyword.modifier
+
+; keyword.repeat
+; --------------
+(foreach_statement
+ .
+ (_)
+ .
+ (_)
+ .
+ "in" @keyword.repeat)
+
+[
+ "while"
+ "repeat"
+ "do"
+ "until"
+ "foreach"
+] @keyword.repeat
+
+; keyword.return
+; --------------
+"return" @keyword.return
+
+; keyword.exception
+; -----------------
+[
+ "try"
+ "catch"
+] @keyword.exception
+
+; keyword.conditional
+; -------------------
+[
+ "if"
+ "else"
+] @keyword.conditional
+
+; keyword.directive.define
+; ------------------------
+"primitive" @keyword.directive.define
+
+; function
+; --------
+(native_function
+ name: (identifier) @function)
+
+(static_function
+ name: (identifier) @function)
+
+(func_identifier) @function
+
+; function.method
+; ---------------
+(init_function
+ "init" @function.method)
+
+(receive_function
+ "receive" @function.method)
+
+(bounced_function
+ "bounced" @function.method)
+
+(external_function
+ "external" @function.method)
+
+(function
+ name: (identifier) @function.method)
+
+; function.call
+; -------------
+(static_call_expression
+ name: (identifier) @function.call)
+
+; function.method.call
+; ---------------
+(method_call_expression
+ name: (identifier) @function.method.call)
+
+; function.builtin
+; ----------------
+(static_call_expression
+ name: (identifier) @function.builtin
+ (#any-of? @function.builtin
+ "log" "log2" "send" "sender" "require" "now" "myBalance" "myAddress" "newAddress"
+ "contractAddress" "contractAddressExt" "emit" "cell" "ton" "dump" "dumpStack" "beginString"
+ "beginComment" "beginTailString" "beginStringFromBuilder" "beginCell" "emptyCell" "randomInt"
+ "random" "checkSignature" "checkDataSignature" "sha256" "min" "max" "abs" "pow" "pow2" "throw"
+ "nativeThrowWhen" "nativeThrowUnless" "getConfigParam" "nativeRandomize" "nativeRandomizeLt"
+ "nativePrepareRandom" "nativeRandom" "nativeRandomInterval" "nativeReserve"))
+
+; comment
+; -------
+(comment) @comment @spell
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
+
+; attribute
+; ---------
+[
+ "@name"
+ "@interface"
+] @attribute
diff --git a/queries/tact/indents.scm b/queries/tact/indents.scm
new file mode 100644
index 000000000..749ab2469
--- /dev/null
+++ b/queries/tact/indents.scm
@@ -0,0 +1,50 @@
+; indent.begin ; indent children when matching this node
+; ------------
+[
+ ; (..., ...)
+ (parameter_list)
+ (argument_list)
+ ; {..., ...}
+ (instance_argument_list)
+ ; {...; ...}
+ (message_body)
+ (struct_body)
+ (contract_body)
+ (trait_body)
+ (function_body)
+ (block_statement)
+ ; misc.
+ (binary_expression)
+ (ternary_expression)
+ (return_statement)
+ (static_call_expression)
+ (method_call_expression)
+] @indent.begin
+
+; indent.branch ; dedent itself when matching this node
+; -------------
+[
+ "}"
+ ")"
+ ">"
+] @indent.branch
+
+; indent.end ; marks the end of indented block
+; ----------
+[
+ "}"
+ ")"
+ ">"
+] @indent.end
+
+; indent.auto ; behaves like 'autoindent' buffer option
+; -----------
+[
+ (comment)
+ (ERROR)
+] @indent.auto
+
+; indent.align ; behaves like python aligned/hanging indent
+; indent.dedent ; dedent children when matching this node
+; indent.ignore ; do not indent in this node
+; indent.zero ; sets this node at position 0 (no indent)
diff --git a/queries/tact/injections.scm b/queries/tact/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/queries/tact/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/queries/tact/locals.scm b/queries/tact/locals.scm
new file mode 100644
index 000000000..87ad953ff
--- /dev/null
+++ b/queries/tact/locals.scm
@@ -0,0 +1,72 @@
+; Scopes @local.scope
+; -------------------------
+[
+ (static_function)
+ (init_function)
+ (bounced_function)
+ (receive_function)
+ (external_function)
+ (function)
+ (block_statement)
+] @local.scope
+
+; Definitions @local.definition
+; ------------------------------
+; variables
+(let_statement
+ name: (identifier) @local.definition.var)
+
+; constants
+(constant
+ name: (identifier) @local.definition.constant)
+
+; functions
+(static_function
+ name: (identifier) @local.definition.function
+ (#set! definition.var.scope parent))
+
+; methods (functions off of contracts and traits)
+(init_function
+ "init" @local.definition.method
+ (#set! definition.var.scope parent))
+
+(bounced_function
+ "bounced" @local.definition.method
+ (#set! definition.var.scope parent))
+
+(receive_function
+ "receive" @local.definition.method
+ (#set! definition.var.scope parent))
+
+(external_function
+ "external" @local.definition.method
+ (#set! definition.var.scope parent))
+
+(function
+ name: (identifier) @local.definition.method
+ (#set! definition.var.scope parent))
+
+; parameters
+(parameter
+ name: (identifier) @local.definition.parameter)
+
+; user-defined types (structs and messages)
+(type_identifier) @local.definition.type
+
+; fields (and properties)
+(field
+ name: (identifier) @local.definition.field)
+
+; imports
+(import_statement
+ (string) @local.definition.import)
+
+; References @local.reference
+; -----------------------------
+(self) @local.reference
+
+(value_expression
+ (identifier) @local.reference)
+
+(lvalue
+ (identifier) @local.reference)