nvim-treesitter/queries/zig/highlights.scm

238 lines
2.8 KiB
Scheme
Raw Normal View History

2021-08-08 18:54:24 +09:00
[
(container_doc_comment)
(doc_comment)
(line_comment)
] @comment
2021-03-23 06:18:43 +05:30
((line_comment) @text.note
(#match? @text.note "^// *zig fmt: (on|off) *$")
)
[
variable: (IDENTIFIER)
variable_type_function: (IDENTIFIER)
] @variable
parameter: (IDENTIFIER) @parameter
2021-03-23 06:18:43 +05:30
[
field_member: (IDENTIFIER)
field_access: (IDENTIFIER)
] @field
2021-03-23 06:18:43 +05:30
;; assume TitleCase is a type
2021-08-08 18:54:24 +09:00
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @type
(#match? @type "^[A-Z]")
2021-08-08 18:54:24 +09:00
)
;; assume camelCase is a function
(
2021-08-08 18:54:24 +09:00
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
parameter: (IDENTIFIER)
] @function
(#match? @function "^[a-z]+[A-Z]+")
)
;; assume all CAPS_1 is a constant
(
[
variable_type_function: (IDENTIFIER)
field_access: (IDENTIFIER)
] @constant
(#match? @constant "^[A-Z][A-Z_0-9]+$")
)
[
function_call: (IDENTIFIER)
function: (IDENTIFIER)
] @function
2021-08-08 18:54:24 +09:00
exception: "!" @exception
2021-08-08 18:54:24 +09:00
(
(IDENTIFIER) @variable.builtin
(#eq? @variable.builtin "_")
)
2021-11-25 20:42:01 +09:00
; (PtrTypeStart "c" @variable.builtin)
; (
; (ContainerDeclType
; (ErrorUnionExpr)
; ; "enum"
; )
; (ContainerField (IDENTIFIER) @constant)
; )
2021-03-23 06:18:43 +05:30
field_constant: (IDENTIFIER) @constant
2021-08-08 18:54:24 +09:00
(BUILTINIDENTIFIER) @function.builtin
2021-03-23 06:18:43 +05:30
2021-08-08 18:54:24 +09:00
((BUILTINIDENTIFIER) @include
(#any-of? @include "@import" "@cImport"))
2021-08-08 18:54:24 +09:00
(INTEGER) @number
2021-03-23 06:18:43 +05:30
2021-08-08 18:54:24 +09:00
(FLOAT) @float
2021-08-08 18:54:24 +09:00
[
(LINESTRING)
2021-08-08 18:54:24 +09:00
(STRINGLITERALSINGLE)
] @string
2021-03-23 06:18:43 +05:30
2021-08-08 18:54:24 +09:00
(CHAR_LITERAL) @character
(EscapeSequence) @string.escape
(FormatSequence) @string.special
2021-03-23 06:18:43 +05:30
[
"allowzero"
"volatile"
2021-08-08 18:54:24 +09:00
"anytype"
"anyframe"
(BuildinTypeExpr)
] @type.builtin
(BreakLabel (IDENTIFIER) @label)
(BlockLabel (IDENTIFIER) @label)
2021-03-23 06:18:43 +05:30
2021-07-08 22:28:51 +02:00
[
"true"
"false"
] @boolean
2021-08-08 18:54:24 +09:00
[
"undefined"
"unreachable"
"null"
] @constant.builtin
2021-03-23 06:18:43 +05:30
[
"else"
"if"
"switch"
] @conditional
[
"for"
"while"
] @repeat
2021-08-08 18:54:24 +09:00
[
"or"
"and"
"orelse"
2021-08-08 18:54:24 +09:00
] @keyword.operator
2021-03-23 06:18:43 +05:30
[
2021-08-08 18:54:24 +09:00
"struct"
"enum"
"union"
"error"
"packed"
"opaque"
] @keyword
2021-03-23 06:18:43 +05:30
[
2021-08-08 18:54:24 +09:00
"try"
"error"
"catch"
] @exception
; VarDecl
[
"const"
"var"
"comptime"
"threadlocal"
"fn"
] @keyword.function
[
"test"
"pub"
"usingnamespace"
] @keyword
[
"return"
"break"
"continue"
] @keyword.return
; Macro
[
"defer"
"errdefer"
"async"
"nosuspend"
"await"
"suspend"
"resume"
"export"
"extern"
] @function.macro
; PrecProc
[
"inline"
"noinline"
"asm"
"callconv"
"noalias"
] @attribute
[
"linksection"
"align"
] @function.builtin
[
(CompareOp)
(BitwiseOp)
(BitShiftOp)
(AdditionOp)
2021-10-21 13:56:32 +09:00
(AssignOp)
2021-08-08 18:54:24 +09:00
(MultiplyOp)
(PrefixOp)
"*"
"**"
"->"
"=>"
".?"
".*"
"?"
2021-03-23 06:18:43 +05:30
] @operator
[
";"
"."
","
2021-08-08 18:54:24 +09:00
":"
2021-03-23 06:18:43 +05:30
] @punctuation.delimiter
[
".."
"..."
] @punctuation.special
2021-08-08 18:54:24 +09:00
[
"["
"]"
"("
")"
"{"
"}"
(Payload "|")
(PtrPayload "|")
(PtrIndexPayload "|")
2021-08-08 18:54:24 +09:00
] @punctuation.bracket
; Error
(ERROR) @error