2022-08-22 20:13:21 +04:00
|
|
|
; ----------
|
|
|
|
; Primitives
|
|
|
|
; ----------
|
|
|
|
|
|
|
|
[
|
|
|
|
(line_comment)
|
|
|
|
(block_comment)
|
|
|
|
] @comment
|
|
|
|
|
2022-11-05 22:30:40 +04:00
|
|
|
(
|
|
|
|
((identifier) @constant.builtin)
|
|
|
|
(#match? @constant.builtin "^(nothing|missing|undef)$"))
|
|
|
|
|
|
|
|
[
|
|
|
|
(true)
|
|
|
|
(false)
|
|
|
|
] @constant.builtin.boolean
|
2022-08-22 20:13:21 +04:00
|
|
|
|
|
|
|
(integer_literal) @constant.numeric.integer
|
|
|
|
(float_literal) @constant.numeric.float
|
|
|
|
|
2022-11-05 22:30:40 +04:00
|
|
|
(
|
|
|
|
((identifier) @constant.numeric.float)
|
|
|
|
(#match? @constant.numeric.float "^((Inf|NaN)(16|32|64)?)$"))
|
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
(character_literal) @constant.character
|
|
|
|
(escape_sequence) @constant.character.escape
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 16:22:48 +04:00
|
|
|
(string_literal) @string
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 16:22:48 +04:00
|
|
|
(prefixed_string_literal
|
2022-08-22 20:13:21 +04:00
|
|
|
prefix: (identifier) @function.macro) @string
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
(quote_expression
|
|
|
|
(identifier) @string.special.symbol)
|
|
|
|
|
|
|
|
; -------------------
|
|
|
|
; Modules and Imports
|
|
|
|
; -------------------
|
|
|
|
|
|
|
|
(module_definition
|
|
|
|
name: (identifier) @namespace)
|
|
|
|
|
|
|
|
(import_statement
|
|
|
|
(identifier) @namespace)
|
|
|
|
|
|
|
|
(selected_import
|
|
|
|
. (identifier) @namespace)
|
|
|
|
|
|
|
|
(scoped_identifier
|
|
|
|
(identifier) @namespace)
|
|
|
|
|
|
|
|
; -----
|
|
|
|
; Types
|
|
|
|
; -----
|
|
|
|
|
|
|
|
(abstract_definition
|
|
|
|
name: (identifier) @type)
|
|
|
|
|
|
|
|
(primitive_definition
|
|
|
|
name: (identifier) @type)
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
(struct_definition
|
|
|
|
name: (identifier) @type)
|
|
|
|
|
|
|
|
(struct_definition
|
|
|
|
. (_)
|
|
|
|
(identifier) @variable.other.member)
|
|
|
|
|
|
|
|
(struct_definition
|
|
|
|
. (_)
|
|
|
|
(typed_expression
|
|
|
|
. (identifier) @variable.other.member))
|
|
|
|
|
|
|
|
(type_parameter_list
|
|
|
|
(identifier) @type)
|
|
|
|
|
2022-11-05 22:30:40 +04:00
|
|
|
(constrained_type_parameter
|
2022-08-22 20:13:21 +04:00
|
|
|
(identifier) @type)
|
|
|
|
|
|
|
|
(subtype_clause
|
|
|
|
(identifier) @type)
|
|
|
|
|
|
|
|
(typed_expression
|
|
|
|
(identifier) @type . )
|
|
|
|
|
|
|
|
(parameterized_identifier
|
|
|
|
(identifier) @type)
|
|
|
|
|
|
|
|
(type_argument_list
|
|
|
|
(identifier) @type)
|
|
|
|
|
2022-11-05 22:30:40 +04:00
|
|
|
(where_clause
|
|
|
|
(identifier) @type)
|
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
; -------------------
|
|
|
|
; Function definition
|
|
|
|
; -------------------
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-24 12:32:08 +04:00
|
|
|
(
|
|
|
|
(function_definition
|
2022-11-05 22:30:40 +04:00
|
|
|
name: [
|
|
|
|
(identifier) @function
|
|
|
|
(scoped_identifier
|
|
|
|
(identifier) @namespace
|
|
|
|
(identifier) @function)
|
|
|
|
])
|
|
|
|
; prevent constructors (PascalCase) to be highlighted as functions
|
|
|
|
(#match? @function "^[^A-Z]"))
|
|
|
|
|
|
|
|
(
|
|
|
|
(short_function_definition
|
|
|
|
name: [
|
|
|
|
(identifier) @function
|
|
|
|
(scoped_identifier
|
|
|
|
(identifier) @namespace
|
|
|
|
(identifier) @function)
|
|
|
|
])
|
2022-08-24 12:32:08 +04:00
|
|
|
; prevent constructors (PascalCase) to be highlighted as functions
|
|
|
|
(#match? @function "^[^A-Z]"))
|
2022-08-22 20:13:21 +04:00
|
|
|
|
2021-07-04 16:24:33 +04:00
|
|
|
(parameter_list
|
2021-09-02 09:58:57 +04:00
|
|
|
(identifier) @variable.parameter)
|
2022-08-22 20:13:21 +04:00
|
|
|
|
2021-07-04 16:24:33 +04:00
|
|
|
(typed_parameter
|
2021-09-02 09:58:57 +04:00
|
|
|
(identifier) @variable.parameter
|
2022-08-22 20:13:21 +04:00
|
|
|
(identifier)? @type)
|
|
|
|
|
|
|
|
(optional_parameter
|
2021-09-02 09:58:57 +04:00
|
|
|
. (identifier) @variable.parameter)
|
2022-08-22 20:13:21 +04:00
|
|
|
|
2022-11-05 22:30:40 +04:00
|
|
|
(slurp_parameter
|
2021-09-02 09:58:57 +04:00
|
|
|
(identifier) @variable.parameter)
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
(function_expression
|
|
|
|
. (identifier) @variable.parameter)
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
; ---------------
|
|
|
|
; Functions calls
|
|
|
|
; ---------------
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-24 12:32:08 +04:00
|
|
|
(
|
|
|
|
(call_expression
|
|
|
|
(identifier) @function)
|
|
|
|
; prevent constructors (PascalCase) to be highlighted as functions
|
|
|
|
(#match? @function "^[^A-Z]"))
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-24 12:32:08 +04:00
|
|
|
(
|
|
|
|
(broadcast_call_expression
|
|
|
|
(identifier) @function)
|
|
|
|
(#match? @function "^[^A-Z]"))
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-24 12:32:08 +04:00
|
|
|
(
|
|
|
|
(call_expression
|
|
|
|
(field_expression (identifier) @function .))
|
|
|
|
(#match? @function "^[^A-Z]"))
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-24 12:32:08 +04:00
|
|
|
(
|
|
|
|
(broadcast_call_expression
|
|
|
|
(field_expression (identifier) @function .))
|
|
|
|
(#match? @function "^[^A-Z]"))
|
2022-08-22 20:13:21 +04:00
|
|
|
|
|
|
|
; ------
|
|
|
|
; Macros
|
|
|
|
; ------
|
|
|
|
|
|
|
|
(macro_definition
|
|
|
|
name: (identifier) @function.macro)
|
2022-08-22 16:22:48 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
(macro_identifier
|
|
|
|
"@" @function.macro
|
|
|
|
(identifier) @function.macro)
|
|
|
|
|
|
|
|
; --------
|
|
|
|
; Keywords
|
|
|
|
; --------
|
|
|
|
|
|
|
|
(function_definition
|
|
|
|
["function" "end"] @keyword.function)
|
2021-07-04 16:24:33 +04:00
|
|
|
|
|
|
|
(if_statement
|
2021-09-02 09:58:57 +04:00
|
|
|
["if" "end"] @keyword.control.conditional)
|
2021-07-04 16:24:33 +04:00
|
|
|
(elseif_clause
|
2021-09-02 09:58:57 +04:00
|
|
|
["elseif"] @keyword.control.conditional)
|
2021-07-04 16:24:33 +04:00
|
|
|
(else_clause
|
2021-09-02 09:58:57 +04:00
|
|
|
["else"] @keyword.control.conditional)
|
2021-07-04 16:24:33 +04:00
|
|
|
(ternary_expression
|
2021-09-02 09:58:57 +04:00
|
|
|
["?" ":"] @keyword.control.conditional)
|
2021-07-04 16:24:33 +04:00
|
|
|
|
|
|
|
(for_statement
|
2021-09-02 09:58:57 +04:00
|
|
|
["for" "end"] @keyword.control.repeat)
|
2021-07-04 16:24:33 +04:00
|
|
|
(while_statement
|
2021-09-02 09:58:57 +04:00
|
|
|
["while" "end"] @keyword.control.repeat)
|
|
|
|
(break_statement) @keyword.control.repeat
|
|
|
|
(continue_statement) @keyword.control.repeat
|
2021-07-04 16:24:33 +04:00
|
|
|
(for_binding
|
2021-09-02 09:58:57 +04:00
|
|
|
"in" @keyword.control.repeat)
|
2021-07-04 16:24:33 +04:00
|
|
|
(for_clause
|
2021-09-02 09:58:57 +04:00
|
|
|
"for" @keyword.control.repeat)
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
(try_statement
|
|
|
|
["try" "end" ] @keyword.control.exception)
|
|
|
|
(finally_clause
|
|
|
|
"finally" @keyword.control.exception)
|
|
|
|
(catch_clause
|
|
|
|
"catch" @keyword.control.exception)
|
2021-07-04 16:24:33 +04:00
|
|
|
|
|
|
|
[
|
2022-08-22 20:13:21 +04:00
|
|
|
"export"
|
2021-07-04 16:24:33 +04:00
|
|
|
"import"
|
2022-08-22 20:13:21 +04:00
|
|
|
"using"
|
2021-09-02 09:58:57 +04:00
|
|
|
] @keyword.control.import
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
[
|
|
|
|
"abstract"
|
2022-11-05 22:30:40 +04:00
|
|
|
"baremodule"
|
2022-08-22 20:13:21 +04:00
|
|
|
"begin"
|
|
|
|
"const"
|
|
|
|
"do"
|
|
|
|
"end"
|
|
|
|
"let"
|
|
|
|
"macro"
|
|
|
|
"module"
|
|
|
|
"mutable"
|
|
|
|
"primitive"
|
|
|
|
"quote"
|
|
|
|
"return"
|
|
|
|
"struct"
|
|
|
|
"type"
|
2022-11-05 22:30:40 +04:00
|
|
|
"where"
|
2022-08-22 20:13:21 +04:00
|
|
|
] @keyword
|
|
|
|
|
|
|
|
; TODO: fix this
|
|
|
|
((identifier) @keyword (match? @keyword "global|local"))
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-22 20:13:21 +04:00
|
|
|
; ---------
|
|
|
|
; Operators
|
|
|
|
; ---------
|
|
|
|
|
|
|
|
[
|
|
|
|
(operator)
|
|
|
|
"::"
|
|
|
|
"<:"
|
|
|
|
":"
|
|
|
|
"=>"
|
|
|
|
"..."
|
|
|
|
"$"
|
|
|
|
] @operator
|
|
|
|
|
|
|
|
; ------------
|
|
|
|
; Punctuations
|
|
|
|
; ------------
|
|
|
|
|
|
|
|
[
|
|
|
|
"."
|
|
|
|
","
|
|
|
|
";"
|
|
|
|
] @punctuation.delimiter
|
|
|
|
|
|
|
|
[
|
|
|
|
"["
|
|
|
|
"]"
|
|
|
|
"("
|
|
|
|
")"
|
|
|
|
"{"
|
|
|
|
"}"
|
|
|
|
] @punctuation.bracket
|
|
|
|
|
|
|
|
; ---------------------
|
|
|
|
; Remaining identifiers
|
|
|
|
; ---------------------
|
|
|
|
|
|
|
|
(const_statement
|
|
|
|
(variable_declaration
|
|
|
|
. (identifier) @constant))
|
2021-07-04 16:24:33 +04:00
|
|
|
|
2022-08-24 12:32:08 +04:00
|
|
|
; SCREAMING_SNAKE_CASE
|
|
|
|
(
|
|
|
|
(identifier) @constant
|
|
|
|
(match? @constant "^[A-Z][A-Z0-9_]*$"))
|
2021-09-02 09:58:57 +04:00
|
|
|
|
2022-08-24 12:32:08 +04:00
|
|
|
; remaining identifiers that start with capital letters should be types (PascalCase)
|
|
|
|
(
|
|
|
|
(identifier) @type
|
|
|
|
(match? @type "^[A-Z]"))
|
|
|
|
|
|
|
|
; Field expressions are either module content or struct fields.
|
|
|
|
; Module types and constants should already be captured, so this
|
|
|
|
; assumes the remaining identifiers to be struct fields.
|
|
|
|
(field_expression
|
|
|
|
(_)
|
|
|
|
(identifier) @variable.other.member)
|
2021-09-02 09:58:57 +04:00
|
|
|
|
|
|
|
(identifier) @variable
|