zed/extensions/zig/languages/zig/highlights.scm
Nils Koch a1ef1d3f76
Add syntax highlighting for character literals in Haskell, PureScript, and Zig (#22609)
Closes #22480

Release Notes:

- N/A

| Before | After |
|----------|----------|
| <img width="344" alt="before"
src="https://github.com/user-attachments/assets/37f8daf7-c9a0-4259-8c03-bd1a4479abca"
/> | <img width="344" alt="after"
src="https://github.com/user-attachments/assets/0f7e4429-e48b-4b32-9797-a0da8487e23e"
/> |

Zig, Haskel, and PureScript define a character caputure name in
`highlights.scm`, but we did not define a color for that capture name in
the themes. The new character color is the same as the string color in
all themes.

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2025-01-03 20:51:43 +00:00

295 lines
3.3 KiB
Scheme

; Variables
(identifier) @variable
; Parameters
(parameter
name: (identifier) @variable.parameter)
; Types
(parameter
type: (identifier) @type)
((identifier) @type
(#match? @type "^[A-Z_][a-zA-Z0-9_]*"))
(variable_declaration
(identifier) @type
"="
[
(struct_declaration)
(enum_declaration)
(union_declaration)
(opaque_declaration)
])
[
(builtin_type)
"anyframe"
] @type.builtin
; Constants
((identifier) @constant
(#match? @constant "^[A-Z][A-Z_0-9]+$"))
[
"null"
"unreachable"
"undefined"
] @constant.builtin
(field_expression
.
member: (identifier) @constant)
(enum_declaration
(container_field
type: (identifier) @constant))
; Labels
(block_label (identifier) @label)
(break_label (identifier) @label)
; Fields
(field_initializer
.
(identifier) @variable.member)
(field_expression
(_)
member: (identifier) @property)
(field_expression
(_)
member: (identifier) @type (#match? @type "^[A-Z_][a-zA-Z0-9_]*"))
(container_field
name: (identifier) @property)
(initializer_list
(assignment_expression
left: (field_expression
.
member: (identifier) @property)))
; Functions
(builtin_identifier) @function.builtin
(call_expression
function: (identifier) @function.call)
(call_expression
function: (field_expression
member: (identifier) @function.call))
(function_declaration
name: (identifier) @function)
; Modules
(variable_declaration
(identifier) @module
(builtin_function
(builtin_identifier) @keyword.import
(#any-of? @keyword.import "@import" "@cImport")))
; Builtins
[
"c"
"..."
] @variable.builtin
((identifier) @variable.builtin
(#eq? @variable.builtin "_"))
(calling_convention
(identifier) @variable.builtin)
; Keywords
[
"asm"
"defer"
"errdefer"
"test"
"error"
"const"
"var"
] @keyword
[
"struct"
"union"
"enum"
"opaque"
] @keyword.type
[
"async"
"await"
"suspend"
"nosuspend"
"resume"
] @keyword.coroutine
"fn" @keyword.function
[
"and"
"or"
"orelse"
] @keyword.operator
"return" @keyword.return
[
"if"
"else"
"switch"
] @keyword.conditional
[
"for"
"while"
"break"
"continue"
] @keyword.repeat
[
"usingnamespace"
"export"
] @keyword.import
[
"try"
"catch"
] @keyword.exception
[
"volatile"
"allowzero"
"noalias"
"addrspace"
"align"
"callconv"
"linksection"
"pub"
"inline"
"noinline"
"extern"
"comptime"
"packed"
"threadlocal"
] @keyword.modifier
; Operator
[
"="
"*="
"*%="
"*|="
"/="
"%="
"+="
"+%="
"+|="
"-="
"-%="
"-|="
"<<="
"<<|="
">>="
"&="
"^="
"|="
"!"
"~"
"-"
"-%"
"&"
"=="
"!="
">"
">="
"<="
"<"
"&"
"^"
"|"
"<<"
">>"
"<<|"
"+"
"++"
"+%"
"-%"
"+|"
"-|"
"*"
"/"
"%"
"**"
"*%"
"*|"
"||"
".*"
".?"
"?"
".."
] @operator
; Literals
(character) @string
([
(string)
(multiline_string)
] @string
(#set! "priority" 95))
(integer) @number
(float) @number.float
(boolean) @boolean
(escape_sequence) @string.escape
; Punctuation
[
"["
"]"
"("
")"
"{"
"}"
] @punctuation.bracket
[
";"
"."
","
":"
"=>"
"->"
] @punctuation.delimiter
(payload "|" @punctuation.bracket)
; Comments
(comment) @comment
((comment) @comment.documentation
(#match? @comment.documentation "^//(/|!)"))