ZIm/crates/languages/src/tsx/highlights.scm
versecafe de5f87e8f2
languages: Add module to TS/JS keywords (#36830)
<img width="376" height="166" alt="image"
src="https://github.com/user-attachments/assets/ae32d74c-387b-4809-a0d6-cfa97888347d"
/>


Release Notes:

- Improved syntax highlights for `module` keyword in TS/JS
2025-08-24 09:54:47 +03:00

260 lines
3.9 KiB
Scheme

; Variables
(identifier) @variable
; Properties
(property_identifier) @property
(shorthand_property_identifier) @property
(shorthand_property_identifier_pattern) @property
(private_property_identifier) @property
; Function and method calls
(call_expression
function: (identifier) @function)
(call_expression
function: (member_expression
property: [(property_identifier) (private_property_identifier)] @function.method))
; Function and method definitions
(function_expression
name: (identifier) @function)
(function_declaration
name: (identifier) @function)
(method_definition
name: [(property_identifier) (private_property_identifier)] @function.method)
(method_definition
name: (property_identifier) @constructor
(#eq? @constructor "constructor"))
(pair
key: [(property_identifier) (private_property_identifier)] @function.method
value: [(function_expression) (arrow_function)])
(assignment_expression
left: (member_expression
property: [(property_identifier) (private_property_identifier)] @function.method)
right: [(function_expression) (arrow_function)])
(variable_declarator
name: (identifier) @function
value: [(function_expression) (arrow_function)])
(assignment_expression
left: (identifier) @function
right: [(function_expression) (arrow_function)])
; Special identifiers
((identifier) @type
(#match? @type "^[A-Z]"))
(type_identifier) @type
(predefined_type) @type.builtin
([
(identifier)
(shorthand_property_identifier)
(shorthand_property_identifier_pattern)
] @constant
(#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
; Literals
(this) @variable.special
(super) @variable.special
[
(null)
(undefined)
] @constant.builtin
[
(true)
(false)
] @boolean
(comment) @comment
[
(string)
(template_string)
(template_literal_type)
] @string
(escape_sequence) @string.escape
(regex) @string.regex
(regex_flags) @keyword.operator.regex
(number) @number
; Tokens
[
";"
"?."
"."
","
":"
"?"
] @punctuation.delimiter
[
"-"
"--"
"-="
"+"
"++"
"+="
"*"
"*="
"**"
"**="
"/"
"/="
"%"
"%="
"<"
"<="
"<<"
"<<="
"="
"=="
"==="
"!"
"!="
"!=="
"=>"
">"
">="
">>"
">>="
">>>"
">>>="
"~"
"^"
"&"
"|"
"^="
"&="
"|="
"&&"
"||"
"??"
"&&="
"||="
"??="
"..."
] @operator
(regex "/" @string.regex)
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
(ternary_expression
[
"?"
":"
] @operator
)
[
"as"
"async"
"await"
"break"
"case"
"catch"
"class"
"const"
"continue"
"debugger"
"default"
"delete"
"do"
"else"
"export"
"extends"
"finally"
"for"
"from"
"function"
"get"
"if"
"import"
"in"
"instanceof"
"is"
"let"
"new"
"of"
"return"
"satisfies"
"set"
"static"
"switch"
"target"
"throw"
"try"
"typeof"
"using"
"var"
"void"
"while"
"with"
"yield"
] @keyword
(template_substitution
"${" @punctuation.special
"}" @punctuation.special) @embedded
(template_type
"${" @punctuation.special
"}" @punctuation.special) @embedded
(type_arguments
"<" @punctuation.bracket
">" @punctuation.bracket)
(decorator "@" @punctuation.special)
; Keywords
[ "abstract"
"declare"
"enum"
"export"
"implements"
"interface"
"keyof"
"module"
"namespace"
"private"
"protected"
"public"
"type"
"readonly"
"override"
] @keyword
; JSX elements
(jsx_opening_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
(jsx_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
(jsx_self_closing_element (identifier) @tag.jsx (#match? @tag.jsx "^[a-z][^.]*$"))
(jsx_attribute (property_identifier) @attribute.jsx)
(jsx_opening_element (["<" ">"]) @punctuation.bracket.jsx)
(jsx_closing_element (["</" ">"]) @punctuation.bracket.jsx)
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket.jsx)
(jsx_attribute "=" @punctuation.delimiter.jsx)
(jsx_text) @text.jsx