mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-08-17 12:00:22 +03:00
Add zig tree-sitter support (#631)
* Add initial zig tree-sitter support * zig/highlights.scm: remove unnecessary queries * Add zig/indents.toml
This commit is contained in:
parent
5cee3b634d
commit
f22e0aa2ae
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -102,3 +102,7 @@
|
||||
path = helix-syntax/languages/tree-sitter-protobuf
|
||||
url = https://github.com/yusdacra/tree-sitter-protobuf.git
|
||||
shallow = true
|
||||
[submodule "helix-syntax/languages/tree-sitter-zig"]
|
||||
path = helix-syntax/languages/tree-sitter-zig
|
||||
url = https://github.com/maxxnino/tree-sitter-zig
|
||||
shallow = true
|
||||
|
1
helix-syntax/languages/tree-sitter-zig
Submodule
1
helix-syntax/languages/tree-sitter-zig
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 049162bea8a44e1a4acd01b06e1c8672d9231a86
|
@ -233,3 +233,15 @@ indent = { tab-width = 4, unit = " " }
|
||||
# comment-token = "--"
|
||||
#
|
||||
# indent = { tab-width = 2, unit = " " }
|
||||
|
||||
[[language]]
|
||||
name = "zig"
|
||||
scope = "source.zig"
|
||||
injection-regex = "zig"
|
||||
file-types = ["zig"]
|
||||
roots = ["build.zig"]
|
||||
auto-format = true
|
||||
comment-token = "//"
|
||||
|
||||
language-server = { command = "zls" }
|
||||
indent = { tab-width = 4, unit = " " }
|
||||
|
198
runtime/queries/zig/highlights.scm
Normal file
198
runtime/queries/zig/highlights.scm
Normal file
@ -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
|
12
runtime/queries/zig/indents.toml
Normal file
12
runtime/queries/zig/indents.toml
Normal file
@ -0,0 +1,12 @@
|
||||
indent = [
|
||||
"block",
|
||||
"match_block",
|
||||
"arguments",
|
||||
"parameters"
|
||||
]
|
||||
|
||||
outdent = [
|
||||
"}",
|
||||
"]",
|
||||
")"
|
||||
]
|
Loading…
Reference in New Issue
Block a user