Skip to content

Commit

Permalink
Overhaul Hare syntax highlight queries
Browse files Browse the repository at this point in the history
  • Loading branch information
omasanori committed Jul 17, 2024
1 parent 22a0514 commit 18dc497
Showing 1 changed file with 92 additions and 59 deletions.
151 changes: 92 additions & 59 deletions runtime/queries/hare/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
; Types

(type) @type
(type "const" @type)

; Keywords

[
"case"
"else"
"if"
"match"
Expand All @@ -19,7 +23,10 @@
"break"
] @keyword.control.repeat

"return" @keyword.control.return
[
"return"
"yield"
] @keyword.control.return

[
"abort"
Expand All @@ -29,69 +36,76 @@
"fn" @keyword.function

[
"alloc"
"append"
"as"
"bool"
"case"
"const"
"nullable"
] @keyword.storage.modifier

[
"const"
"def"
"defer"
"delete"
"enum"
"free"
"is"
"len"
"let"
"match"
"nullable"
"offset"
"struct"
"type"
"union"
"yield"
] @keyword.storage.type

[
"append"
"as"
"defer"
"delete"
"insert"
"is"
"static"
"type"
"vaarg"
"vaend"
"vastart"
"_"
] @keyword

"static" @keyword.storage.modifier
; Operators

[
"."
"!"
"~"
"?"
"*"
"."
"!"
"~"
"?"
"*"
"/"
"%"
"+"
"-"
"<<"
"%"
"+"
"-"
"<<"
">>"
"::"
"<"
"<="
">"
"::"
"<"
"<="
">"
">="
"=="
"!="
"&"
"|"
"^"
"&&"
"=="
"!="
"&"
"|"
"^"
"&&"
"||"
"="
"+="
"-="
"*="
"/="
"%="
"&="
"|="
"<<="
">>="
"="
"+="
"-="
"*="
"/="
"%="
"&="
"|="
"<<="
">>="
"^="
"=>"
] @operator

; Other symbols

[
"("
")"
Expand All @@ -107,36 +121,55 @@
";"
] @punctuation.delimiter

"..." @special
"..." @special

; Comments

(comment) @comment

; Literals

"null" @constant.builtin

[
"false"
"null"
"true"
] @constant.builtin
(literal "void") @constant.builtin
] @constant.builtin.boolean

(string_literal) @string
(escape_sequence) @constant.character.escape
(rune_literal) @string
(integer_literal) @constant.numeric.integer
(floating_literal) @constant.numeric.float
(rune_literal) @constant.character
(escape_sequence) @constant.character.escape
(string_literal) @string

; Functions

(call_expression
(postfix_expression) @function)
(size_expression "size" @function.builtin)
(allocation_expression
"alloc" @function.builtin)
(allocation_expression
"free" @function.builtin)
(align_expression
"align" @function.builtin)
(size_expression
"size" @function.builtin)
(length_expression
"len" @function.builtin)
(offset_expression
"offset" @function.builtin)

(function_declaration
name: (identifier) @function)

(parameter (name) @variable.parameter)
; Variables

(parameter
(name) @variable.parameter)

(field_access_expression
selector: (name) @variable.other.member)
(decl_attr) @special
(fndec_attrs) @special

(identifier) @variable
(struct_union_field (name)) @variable
(struct_union_field
(name) @variable)

0 comments on commit 18dc497

Please sign in to comment.