aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorvoroskoi2021-08-28 04:32:01 +0000
committerGitHub2021-08-28 04:32:01 +0000
commitf22e0aa2ae4169851b43d2225e6a43ef36442659 (patch)
tree11d8398400a72d55575213b84ce68ccb54810efa /runtime
parent5cee3b634d3763dfdb0312d1dc58f6ebcfccb4bf (diff)
Add zig tree-sitter support (#631)
* Add initial zig tree-sitter support * zig/highlights.scm: remove unnecessary queries * Add zig/indents.toml
Diffstat (limited to 'runtime')
-rw-r--r--runtime/queries/zig/highlights.scm198
-rw-r--r--runtime/queries/zig/indents.toml12
2 files changed, 210 insertions, 0 deletions
diff --git a/runtime/queries/zig/highlights.scm b/runtime/queries/zig/highlights.scm
new file mode 100644
index 00000000..5a3d62dc
--- /dev/null
+++ b/runtime/queries/zig/highlights.scm
@@ -0,0 +1,198 @@
+[
+ (container_doc_comment)
+ (doc_comment)
+ (line_comment)
+] @comment
+
+; field in top level decl, and in struct, union...
+(ContainerField
+ (IDENTIFIER) @property
+ (SuffixExpr (IDENTIFIER) @type)?
+)
+
+; error.OutOfMemory;
+(SuffixExpr
+ "error"
+ "."
+ (IDENTIFIER) @constant
+)
+
+; var x: IDENTIFIER
+type: (SuffixExpr (IDENTIFIER) @type)
+
+; IDENTIFIER{}
+constructor: (SuffixExpr (IDENTIFIER) @constructor)
+
+; fields
+(FieldInit (IDENTIFIER) @property)
+
+; foo.bar.baz.function() calls
+(
+ (SuffixOp
+ (IDENTIFIER) @function
+ )
+ .
+ (FnCallArguments)
+)
+
+; function() calls
+(
+ (
+ (IDENTIFIER) @function
+ )
+ .
+ (FnCallArguments)
+)
+
+; functionn decl
+(FnProto
+ (IDENTIFIER) @function
+ (SuffixExpr (IDENTIFIER) @type)?
+ ("!")? @function.macro
+)
+
+; function parameters and types
+(ParamDecl
+ (IDENTIFIER) @variable.parameter
+ ":"
+ [
+ (ParamType (SuffixExpr (IDENTIFIER) @type))
+ (ParamType)
+ ]
+)
+
+; switch
+(SwitchItem
+ (SuffixExpr
+ "."
+ .
+ (IDENTIFIER) @constant
+ )
+)
+
+(INTEGER) @number
+
+(FLOAT) @number
+
+[
+ (STRINGLITERAL)
+ (STRINGLITERALSINGLE)
+] @string
+
+(CHAR_LITERAL) @string
+
+[
+ "allowzero"
+ "volatile"
+ "anytype"
+ "anyframe"
+ (BuildinTypeExpr)
+] @type.builtin
+
+(BreakLabel (IDENTIFIER) @label)
+(BlockLabel (IDENTIFIER) @label)
+
+[
+ "true"
+ "false"
+ "undefined"
+ "unreachable"
+ "null"
+] @constant.builtin
+
+[
+ "else"
+ "if"
+ "switch"
+ "for"
+ "while"
+ "return"
+ "break"
+ "continue"
+ "defer"
+ "errdefer"
+ "async"
+ "nosuspend"
+ "await"
+ "suspend"
+ "resume"
+ "try"
+ "catch"
+] @keyword.control
+
+[
+ "struct"
+ "enum"
+ "union"
+ "error"
+ "packed"
+ "opaque"
+ "test"
+ "usingnamespace"
+ "export"
+ "extern"
+ "const"
+ "var"
+ "comptime"
+ "threadlocal"
+] @keyword
+
+[
+ "pub"
+ "fn"
+] @keyword.function
+
+; PrecProc
+[
+ "inline"
+ "noinline"
+ "asm"
+ "callconv"
+ "noalias"
+] @attribute
+
+[
+ (BUILTINIDENTIFIER)
+ "linksection"
+ "align"
+] @function.builtin
+
+[
+ (CompareOp)
+ (BitwiseOp)
+ (BitShiftOp)
+ (AdditionOp)
+ (MultiplyOp)
+ (PrefixOp)
+ "or"
+ "and"
+ "orelse"
+ "*"
+ "**"
+ "->"
+ "=>"
+ ".?"
+ ".*"
+ "="
+] @operator
+
+[
+ ";"
+ "."
+ ","
+ ":"
+] @punctuation.delimiter
+
+[
+ ".."
+ "..."
+ "["
+ "]"
+ "("
+ ")"
+ "{"
+ "}"
+ (Payload "|")
+ (PtrPayload "|")
+ (PtrIndexPayload "|")
+] @punctuation
diff --git a/runtime/queries/zig/indents.toml b/runtime/queries/zig/indents.toml
new file mode 100644
index 00000000..e119078b
--- /dev/null
+++ b/runtime/queries/zig/indents.toml
@@ -0,0 +1,12 @@
+indent = [
+ "block",
+ "match_block",
+ "arguments",
+ "parameters"
+]
+
+outdent = [
+ "}",
+ "]",
+ ")"
+]