2021-04-08 16:18:25 +02:00
|
|
|
; Identifier conventions
|
|
|
|
|
2021-05-16 11:58:27 +02:00
|
|
|
|
2021-04-08 16:18:25 +02:00
|
|
|
; Assume all-caps names are constants
|
|
|
|
((identifier) @constant
|
|
|
|
(#match? @constant "^[A-Z][A-Z\\d_]+$'"))
|
|
|
|
|
2021-05-16 11:58:27 +02:00
|
|
|
; Assume other uppercase names are enum constructors
|
|
|
|
((identifier) @constructor
|
|
|
|
(#match? @constructor "^[A-Z]"))
|
|
|
|
|
2021-04-08 16:18:25 +02:00
|
|
|
; Assume that uppercase names in paths are types
|
2021-05-16 11:58:27 +02:00
|
|
|
(mod_item
|
|
|
|
name: (identifier) @namespace)
|
|
|
|
(scoped_identifier
|
|
|
|
path: (identifier) @namespace)
|
|
|
|
(scoped_identifier
|
|
|
|
(scoped_identifier
|
|
|
|
name: (identifier) @namespace))
|
|
|
|
(scoped_type_identifier
|
|
|
|
path: (identifier) @namespace)
|
|
|
|
(scoped_type_identifier
|
|
|
|
(scoped_identifier
|
|
|
|
name: (identifier) @namespace))
|
|
|
|
|
2021-04-08 16:18:25 +02:00
|
|
|
((scoped_identifier
|
|
|
|
path: (identifier) @type)
|
|
|
|
(#match? @type "^[A-Z]"))
|
|
|
|
((scoped_identifier
|
|
|
|
path: (scoped_identifier
|
|
|
|
name: (identifier) @type))
|
|
|
|
(#match? @type "^[A-Z]"))
|
|
|
|
|
2021-05-16 11:58:27 +02:00
|
|
|
; Namespaces
|
|
|
|
|
|
|
|
(crate) @namespace
|
|
|
|
(scoped_use_list
|
|
|
|
path: (identifier) @namespace)
|
|
|
|
(scoped_use_list
|
|
|
|
path: (scoped_identifier
|
|
|
|
(identifier) @namespace))
|
|
|
|
(use_list (scoped_identifier (identifier) @namespace . (_)))
|
2021-04-08 16:18:25 +02:00
|
|
|
|
|
|
|
; Function calls
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
function: (identifier) @function)
|
|
|
|
(call_expression
|
|
|
|
function: (field_expression
|
|
|
|
field: (field_identifier) @function.method))
|
|
|
|
(call_expression
|
|
|
|
function: (scoped_identifier
|
|
|
|
"::"
|
|
|
|
name: (identifier) @function))
|
|
|
|
|
|
|
|
(generic_function
|
|
|
|
function: (identifier) @function)
|
|
|
|
(generic_function
|
|
|
|
function: (scoped_identifier
|
|
|
|
name: (identifier) @function))
|
|
|
|
(generic_function
|
|
|
|
function: (field_expression
|
|
|
|
field: (field_identifier) @function.method))
|
|
|
|
|
2021-05-16 11:58:27 +02:00
|
|
|
; (macro_invocation
|
|
|
|
; macro: (identifier) @function.macro
|
|
|
|
; "!" @function.macro)
|
|
|
|
(macro_invocation
|
|
|
|
macro: (identifier) @function.macro)
|
2021-04-08 16:18:25 +02:00
|
|
|
(macro_invocation
|
2021-05-16 11:58:27 +02:00
|
|
|
macro: (scoped_identifier
|
|
|
|
(identifier) @function.macro .))
|
|
|
|
|
|
|
|
; (metavariable) @variable
|
|
|
|
(metavariable) @function.macro
|
|
|
|
|
|
|
|
"$" @function.macro
|
2021-04-08 16:18:25 +02:00
|
|
|
|
|
|
|
; Function definitions
|
|
|
|
|
|
|
|
(function_item (identifier) @function)
|
|
|
|
(function_signature_item (identifier) @function)
|
|
|
|
|
|
|
|
; Other identifiers
|
|
|
|
|
|
|
|
(type_identifier) @type
|
|
|
|
(primitive_type) @type.builtin
|
|
|
|
(field_identifier) @property
|
|
|
|
|
|
|
|
(line_comment) @comment
|
|
|
|
(block_comment) @comment
|
|
|
|
|
|
|
|
"(" @punctuation.bracket
|
|
|
|
")" @punctuation.bracket
|
|
|
|
"[" @punctuation.bracket
|
|
|
|
"]" @punctuation.bracket
|
|
|
|
|
|
|
|
(type_arguments
|
|
|
|
"<" @punctuation.bracket
|
|
|
|
">" @punctuation.bracket)
|
|
|
|
(type_parameters
|
|
|
|
"<" @punctuation.bracket
|
|
|
|
">" @punctuation.bracket)
|
|
|
|
|
|
|
|
"::" @punctuation.delimiter
|
|
|
|
"." @punctuation.delimiter
|
|
|
|
";" @punctuation.delimiter
|
|
|
|
|
|
|
|
(parameter (identifier) @variable.parameter)
|
2021-05-16 11:58:27 +02:00
|
|
|
(closure_parameters (_) @variable.parameter)
|
2021-04-08 16:18:25 +02:00
|
|
|
|
|
|
|
(lifetime (identifier) @label)
|
|
|
|
|
|
|
|
"break" @keyword
|
|
|
|
"const" @keyword
|
|
|
|
"continue" @keyword
|
2021-04-13 10:06:35 +02:00
|
|
|
(crate) @keyword
|
2021-04-08 16:18:25 +02:00
|
|
|
"default" @keyword
|
|
|
|
"dyn" @keyword
|
|
|
|
"else" @keyword
|
|
|
|
"enum" @keyword
|
|
|
|
"extern" @keyword
|
|
|
|
"fn" @keyword
|
|
|
|
"for" @keyword
|
|
|
|
"if" @keyword
|
|
|
|
"impl" @keyword
|
|
|
|
"in" @keyword
|
|
|
|
"let" @keyword
|
|
|
|
"let" @keyword
|
|
|
|
"loop" @keyword
|
|
|
|
"macro_rules!" @keyword
|
|
|
|
"match" @keyword
|
|
|
|
"mod" @keyword
|
|
|
|
"move" @keyword
|
|
|
|
"pub" @keyword
|
|
|
|
"ref" @keyword
|
|
|
|
"return" @keyword
|
|
|
|
"static" @keyword
|
|
|
|
"struct" @keyword
|
|
|
|
"trait" @keyword
|
|
|
|
"type" @keyword
|
|
|
|
"union" @keyword
|
|
|
|
"unsafe" @keyword
|
|
|
|
"use" @keyword
|
|
|
|
"where" @keyword
|
|
|
|
"while" @keyword
|
|
|
|
(mutable_specifier) @keyword
|
|
|
|
(use_list (self) @keyword)
|
|
|
|
(scoped_use_list (self) @keyword)
|
|
|
|
(scoped_identifier (self) @keyword)
|
|
|
|
(super) @keyword
|
2021-05-16 11:58:27 +02:00
|
|
|
"as" @keyword
|
2021-04-08 16:18:25 +02:00
|
|
|
|
|
|
|
(self) @variable.builtin
|
|
|
|
|
2021-04-08 16:25:54 +02:00
|
|
|
[
|
|
|
|
(char_literal)
|
|
|
|
(string_literal)
|
|
|
|
(raw_string_literal)
|
|
|
|
] @string
|
2021-04-08 16:18:25 +02:00
|
|
|
|
|
|
|
(boolean_literal) @constant.builtin
|
2021-04-08 16:25:54 +02:00
|
|
|
(integer_literal) @number
|
|
|
|
(float_literal) @number
|
2021-04-08 16:18:25 +02:00
|
|
|
|
|
|
|
(escape_sequence) @escape
|
|
|
|
|
|
|
|
(attribute_item) @attribute
|
|
|
|
(inner_attribute_item) @attribute
|
|
|
|
|
2021-05-16 11:58:27 +02:00
|
|
|
[
|
|
|
|
"*"
|
|
|
|
"'"
|
|
|
|
"->"
|
|
|
|
"=>"
|
|
|
|
"<="
|
|
|
|
"="
|
|
|
|
"=="
|
|
|
|
"!"
|
|
|
|
"!="
|
|
|
|
"%"
|
|
|
|
"%="
|
|
|
|
"&"
|
|
|
|
"&="
|
|
|
|
"&&"
|
|
|
|
"|"
|
|
|
|
"|="
|
|
|
|
"||"
|
|
|
|
"^"
|
|
|
|
"^="
|
|
|
|
"*"
|
|
|
|
"*="
|
|
|
|
"-"
|
|
|
|
"-="
|
|
|
|
"+"
|
|
|
|
"+="
|
|
|
|
"/"
|
|
|
|
"/="
|
|
|
|
">"
|
|
|
|
"<"
|
|
|
|
">="
|
|
|
|
">>"
|
|
|
|
"<<"
|
|
|
|
">>="
|
|
|
|
"@"
|
|
|
|
".."
|
|
|
|
"..="
|
|
|
|
"'"
|
|
|
|
] @operator
|
|
|
|
|
|
|
|
"?" @special
|