2022-04-14 12:01:23 +08:00
|
|
|
; CREDITS @stumash (stuart.mashaal@gmail.com)
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(class_definition
|
|
|
|
name: (identifier) @type)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(enum_definition
|
|
|
|
name: (identifier) @type)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(object_definition
|
|
|
|
name: (identifier) @type)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(trait_definition
|
|
|
|
name: (identifier) @type)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(full_enum_case
|
|
|
|
name: (identifier) @type)
|
|
|
|
|
|
|
|
(simple_enum_case
|
|
|
|
name: (identifier) @type)
|
|
|
|
|
|
|
|
;; variables
|
|
|
|
|
|
|
|
(class_parameter
|
|
|
|
name: (identifier) @parameter)
|
|
|
|
|
|
|
|
(self_type (identifier) @parameter)
|
|
|
|
|
|
|
|
(interpolation (identifier) @none)
|
|
|
|
(interpolation (block) @none)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
;; types
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(type_definition
|
|
|
|
name: (type_identifier) @type.definition)
|
|
|
|
|
2022-04-14 12:01:23 +08:00
|
|
|
(type_identifier) @type
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
;; val/var definitions/declarations
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(val_definition
|
|
|
|
pattern: (identifier) @variable)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(var_definition
|
|
|
|
pattern: (identifier) @variable)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(val_declaration
|
|
|
|
name: (identifier) @variable)
|
|
|
|
|
|
|
|
(var_declaration
|
|
|
|
name: (identifier) @variable)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
; method definition
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(function_declaration
|
|
|
|
name: (identifier) @method)
|
|
|
|
|
|
|
|
(function_definition
|
|
|
|
name: (identifier) @method)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
; imports/exports
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
(import_declaration
|
|
|
|
path: (identifier) @namespace)
|
|
|
|
((stable_identifier (identifier) @namespace))
|
|
|
|
|
|
|
|
((import_declaration
|
|
|
|
path: (identifier) @type) (#lua-match? @type "^[A-Z]"))
|
|
|
|
((stable_identifier (identifier) @type) (#lua-match? @type "^[A-Z]"))
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(export_declaration
|
|
|
|
path: (identifier) @namespace)
|
|
|
|
((stable_identifier (identifier) @namespace))
|
|
|
|
|
|
|
|
((export_declaration
|
|
|
|
path: (identifier) @type) (#lua-match? @type "^[A-Z]"))
|
|
|
|
((stable_identifier (identifier) @type) (#lua-match? @type "^[A-Z]"))
|
|
|
|
|
|
|
|
((namespace_selectors (identifier) @type) (#lua-match? @type "^[A-Z]"))
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
; method invocation
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(call_expression
|
|
|
|
function: (identifier) @function.call)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
(call_expression
|
2023-06-18 14:17:38 +08:00
|
|
|
function: (operator_identifier) @function.call)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
(call_expression
|
|
|
|
function: (field_expression
|
2023-06-18 14:17:38 +08:00
|
|
|
field: (identifier) @method.call))
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
((call_expression
|
|
|
|
function: (identifier) @constructor)
|
|
|
|
(#lua-match? @constructor "^[A-Z]"))
|
|
|
|
|
|
|
|
(generic_function
|
2023-06-18 14:17:38 +08:00
|
|
|
function: (identifier) @function.call)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(interpolated_string_expression
|
|
|
|
interpolator: (identifier) @function.call)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
; function definitions
|
|
|
|
|
|
|
|
(function_definition
|
|
|
|
name: (identifier) @function)
|
|
|
|
|
|
|
|
(parameter
|
|
|
|
name: (identifier) @parameter)
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(binding
|
|
|
|
name: (identifier) @parameter)
|
2022-04-14 12:01:23 +08:00
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
; expressions
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
(field_expression field: (identifier) @property)
|
|
|
|
(field_expression value: (identifier) @type
|
|
|
|
(#lua-match? @type "^[A-Z]"))
|
|
|
|
|
|
|
|
(infix_expression operator: (identifier) @operator)
|
|
|
|
(infix_expression operator: (operator_identifier) @operator)
|
|
|
|
(infix_type operator: (operator_identifier) @operator)
|
|
|
|
(infix_type operator: (operator_identifier) @operator)
|
|
|
|
|
|
|
|
; literals
|
|
|
|
|
|
|
|
(boolean_literal) @boolean
|
|
|
|
(integer_literal) @number
|
|
|
|
(floating_point_literal) @float
|
|
|
|
|
|
|
|
[
|
2023-06-18 14:17:38 +08:00
|
|
|
(symbol_literal)
|
|
|
|
(string)
|
|
|
|
(character_literal)
|
|
|
|
(interpolated_string_expression)
|
2022-04-14 12:01:23 +08:00
|
|
|
] @string
|
|
|
|
|
|
|
|
(interpolation "$" @punctuation.special)
|
|
|
|
|
|
|
|
;; keywords
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
(opaque_modifier) @type.qualifier
|
|
|
|
(infix_modifier) @keyword
|
|
|
|
(transparent_modifier) @type.qualifier
|
|
|
|
(open_modifier) @type.qualifier
|
|
|
|
|
2022-04-14 12:01:23 +08:00
|
|
|
[
|
|
|
|
"case"
|
|
|
|
"class"
|
2023-06-18 14:17:38 +08:00
|
|
|
"enum"
|
2022-04-14 12:01:23 +08:00
|
|
|
"extends"
|
2023-06-18 14:17:38 +08:00
|
|
|
"derives"
|
2022-04-14 12:01:23 +08:00
|
|
|
"finally"
|
|
|
|
;; `forSome` existential types not implemented yet
|
|
|
|
;; `macro` not implemented yet
|
|
|
|
"object"
|
|
|
|
"override"
|
|
|
|
"package"
|
|
|
|
"trait"
|
|
|
|
"type"
|
|
|
|
"val"
|
|
|
|
"var"
|
|
|
|
"with"
|
2023-06-18 14:17:38 +08:00
|
|
|
"given"
|
|
|
|
"using"
|
|
|
|
"end"
|
|
|
|
"implicit"
|
|
|
|
"extension"
|
|
|
|
"with"
|
2022-04-14 12:01:23 +08:00
|
|
|
] @keyword
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
[
|
|
|
|
"abstract"
|
|
|
|
"final"
|
|
|
|
"lazy"
|
|
|
|
"sealed"
|
|
|
|
"private"
|
|
|
|
"protected"
|
|
|
|
] @type.qualifier
|
|
|
|
|
|
|
|
(inline_modifier) @storageclass
|
|
|
|
|
|
|
|
(null_literal) @constant.builtin
|
|
|
|
|
|
|
|
(wildcard) @parameter
|
|
|
|
|
|
|
|
(annotation) @attribute
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
;; special keywords
|
|
|
|
|
|
|
|
"new" @keyword.operator
|
|
|
|
|
|
|
|
[
|
|
|
|
"else"
|
|
|
|
"if"
|
|
|
|
"match"
|
2023-06-18 14:17:38 +08:00
|
|
|
"then"
|
2022-04-14 12:01:23 +08:00
|
|
|
] @conditional
|
|
|
|
|
|
|
|
[
|
|
|
|
"("
|
|
|
|
")"
|
|
|
|
"["
|
|
|
|
"]"
|
|
|
|
"{"
|
|
|
|
"}"
|
|
|
|
] @punctuation.bracket
|
|
|
|
|
|
|
|
[
|
|
|
|
"."
|
|
|
|
","
|
|
|
|
] @punctuation.delimiter
|
|
|
|
|
|
|
|
[
|
|
|
|
"do"
|
|
|
|
"for"
|
|
|
|
"while"
|
|
|
|
"yield"
|
|
|
|
] @repeat
|
|
|
|
|
|
|
|
"def" @keyword.function
|
|
|
|
|
|
|
|
[
|
|
|
|
"=>"
|
|
|
|
"<-"
|
|
|
|
"@"
|
|
|
|
] @operator
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
["import" "export"] @include
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
[
|
|
|
|
"try"
|
|
|
|
"catch"
|
|
|
|
"throw"
|
|
|
|
] @exception
|
|
|
|
|
|
|
|
"return" @keyword.return
|
|
|
|
|
2023-06-18 14:17:38 +08:00
|
|
|
[
|
|
|
|
(comment)
|
|
|
|
(block_comment)
|
|
|
|
] @comment @spell
|
|
|
|
|
|
|
|
((block_comment) @comment.documentation
|
|
|
|
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
2022-04-14 12:01:23 +08:00
|
|
|
|
|
|
|
;; `case` is a conditional keyword in case_block
|
|
|
|
|
|
|
|
(case_block
|
|
|
|
(case_clause ("case") @conditional))
|
2023-06-18 14:17:38 +08:00
|
|
|
|
|
|
|
(operator_identifier) @operator
|
|
|
|
|
|
|
|
((identifier) @type (#lua-match? @type "^[A-Z]"))
|
|
|
|
((identifier) @variable.builtin
|
|
|
|
(#lua-match? @variable.builtin "^this$"))
|
|
|
|
|
|
|
|
(
|
|
|
|
(identifier) @function.builtin
|
|
|
|
(#lua-match? @function.builtin "^super$")
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Scala CLI using directives
|
|
|
|
(using_directive_key) @parameter
|
|
|
|
(using_directive_value) @string
|