Zig tree-sitter rework (#811)

- update tree-sitter-zig subproject
- use highlights.scm from upstream, just use helix scopes
- update indents.toml, this one actually works
imgbot
voroskoi 3 years ago committed by GitHub
parent c4ae17dfd4
commit 0e06c10d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1 +1 @@
Subproject commit 049162bea8a44e1a4acd01b06e1c8672d9231a86 Subproject commit 1f27fd1dfe7f352408f01b4894c7825f3a1d6c47

@ -4,82 +4,89 @@
(line_comment) (line_comment)
] @comment ] @comment
; field in top level decl, and in struct, union... [
(ContainerField variable: (IDENTIFIER)
(IDENTIFIER) @property variable_type_function: (IDENTIFIER)
(SuffixExpr (IDENTIFIER) @type)? ] @variable
)
; error.OutOfMemory; parameter: (IDENTIFIER) @variable.parameter
(SuffixExpr
"error" [
"." field_member: (IDENTIFIER)
(IDENTIFIER) @constant field_access: (IDENTIFIER)
] @variable.property
;; assume TitleCase is a type
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @type
(#match? @type "^[A-Z]([a-z]+[A-Za-z0-9]*)*$")
)
;; assume camelCase is a function
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @function
(#match? @function "^[a-z]+([A-Z][a-z0-9]*)+$")
) )
; var x: IDENTIFIER ;; assume all CAPS_1 is a constant
type: (SuffixExpr (IDENTIFIER) @type) (
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
] @constant
(#match? @constant "^[A-Z][A-Z_0-9]+$")
)
; IDENTIFIER{} [
constructor: (SuffixExpr (IDENTIFIER) @constructor) function_call: (IDENTIFIER)
function: (IDENTIFIER)
] @function
; fields exception: "!" @function.macro
(FieldInit (IDENTIFIER) @property)
; foo.bar.baz.function() calls
( (
(SuffixOp (IDENTIFIER) @variable.builtin
(IDENTIFIER) @function (#eq? @variable.builtin "_")
)
.
(FnCallArguments)
) )
; function() calls (PtrTypeStart "c" @variable.builtin)
( (
( (ContainerDeclType
(IDENTIFIER) @function [
(ErrorUnionExpr)
"enum"
]
) )
. (ContainerField (IDENTIFIER) @constant)
(FnCallArguments)
) )
; functionn decl field_constant: (IDENTIFIER) @constant
(FnProto
(IDENTIFIER) @function
(SuffixExpr (IDENTIFIER) @type)?
("!")? @function.macro
)
; function parameters and types (BUILTINIDENTIFIER) @function.builtin
(ParamDecl
(IDENTIFIER) @variable.parameter
":"
[
(ParamType (SuffixExpr (IDENTIFIER) @type))
(ParamType)
]
)
; switch ((BUILTINIDENTIFIER) @keyword.control.import
(SwitchItem (#any-of? @keyword.control.import "@import" "@cImport"))
(SuffixExpr
"."
.
(IDENTIFIER) @constant
)
)
(INTEGER) @number (INTEGER) @number
(FLOAT) @number (FLOAT) @number
[ [
(STRINGLITERAL) (LINESTRING)
(STRINGLITERALSINGLE) (STRINGLITERALSINGLE)
] @string ] @string
(CHAR_LITERAL) @string (CHAR_LITERAL) @constant.character
(EscapeSequence) @escape
(FormatSequence) @string.special
[ [
"allowzero" "allowzero"
@ -95,6 +102,9 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
[ [
"true" "true"
"false" "false"
] @constant.builtin.boolean
[
"undefined" "undefined"
"unreachable" "unreachable"
"null" "null"
@ -104,21 +114,18 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
"else" "else"
"if" "if"
"switch" "switch"
] @keyword.control.conditional
[
"for" "for"
"while" "while"
"return" ] @keyword.control.repeat
"break"
"continue" [
"defer" "or"
"errdefer" "and"
"async" "orelse"
"nosuspend" ] @operator
"await"
"suspend"
"resume"
"try"
"catch"
] @keyword.control
[ [
"struct" "struct"
@ -127,21 +134,48 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
"error" "error"
"packed" "packed"
"opaque" "opaque"
"test"
"usingnamespace"
"export"
"extern"
"const"
"var"
"comptime"
"threadlocal"
] @keyword ] @keyword
[ [
"pub" "try"
"error"
"catch"
] @function.macro
; VarDecl
[
"comptime"
"threadlocal"
"fn" "fn"
] @keyword.function ] @keyword.function
[
"const"
"var"
"test"
"pub"
"usingnamespace"
] @keyword
[
"return"
"break"
"continue"
] @keyword.control
; Macro
[
"defer"
"errdefer"
"async"
"nosuspend"
"await"
"suspend"
"resume"
"export"
"extern"
] @function.macro
; PrecProc ; PrecProc
[ [
"inline" "inline"
@ -149,10 +183,9 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
"asm" "asm"
"callconv" "callconv"
"noalias" "noalias"
] @attribute ] @keyword.directive
[ [
(BUILTINIDENTIFIER)
"linksection" "linksection"
"align" "align"
] @function.builtin ] @function.builtin
@ -164,9 +197,6 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
(AdditionOp) (AdditionOp)
(MultiplyOp) (MultiplyOp)
(PrefixOp) (PrefixOp)
"or"
"and"
"orelse"
"*" "*"
"**" "**"
"->" "->"
@ -174,6 +204,7 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
".?" ".?"
".*" ".*"
"=" "="
"?"
] @operator ] @operator
[ [
@ -186,6 +217,9 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
[ [
".." ".."
"..." "..."
] @punctuation.special
[
"[" "["
"]" "]"
"(" "("
@ -195,4 +229,7 @@ constructor: (SuffixExpr (IDENTIFIER) @constructor)
(Payload "|") (Payload "|")
(PtrPayload "|") (PtrPayload "|")
(PtrIndexPayload "|") (PtrIndexPayload "|")
] @punctuation ] @punctuation.bracket
; Error
(ERROR) @keyword

@ -1,8 +1,9 @@
indent = [ indent = [
"block", "Block",
"match_block", "BlockExpr",
"arguments", "ContainerDecl",
"parameters" "SwitchExpr",
"InitList"
] ]
outdent = [ outdent = [

Loading…
Cancel
Save