Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/rust/highlights.scm')
-rw-r--r--runtime/queries/rust/highlights.scm70
1 files changed, 19 insertions, 51 deletions
diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm
index cc8380cb..6be50825 100644
--- a/runtime/queries/rust/highlights.scm
+++ b/runtime/queries/rust/highlights.scm
@@ -79,19 +79,18 @@
; Types
; -------
-(type_parameter
+(type_parameters
+ (type_identifier) @type.parameter)
+(constrained_type_parameter
+ left: (type_identifier) @type.parameter)
+(optional_type_parameter
name: (type_identifier) @type.parameter)
((type_arguments (type_identifier) @constant)
(#match? @constant "^[A-Z_]+$"))
(type_arguments (type_identifier) @type)
-; `_` in `(_, _)`
(tuple_struct_pattern "_" @comment.unused)
-; `_` in `Vec<_>`
((type_arguments (type_identifier) @comment.unused)
(#eq? @comment.unused "_"))
-; `_` in `Rc<[_]>`
-((array_type (type_identifier) @comment.unused)
- (#eq? @comment.unused "_"))
; ---
; Primitives
@@ -107,29 +106,12 @@
(string_literal)
(raw_string_literal)
] @string
-
-; -------
-; Comments
-; -------
-
-(shebang) @comment
-(line_comment) @comment.line
-(block_comment) @comment.block
-
-; Doc Comments
-(line_comment
- (outer_doc_comment_marker "/" @comment.line.documentation)
- (doc_comment)) @comment.line.documentation
-(line_comment
- (inner_doc_comment_marker "!" @comment.line.documentation)
- (doc_comment)) @comment.line.documentation
-
-(block_comment
- (outer_doc_comment_marker) @comment.block.documentation
- (doc_comment) "*/" @comment.block.documentation) @comment.block.documentation
-(block_comment
- (inner_doc_comment_marker) @comment.block.documentation
- (doc_comment) "*/" @comment.block.documentation) @comment.block.documentation
+(outer_doc_comment_marker "/" @comment)
+(inner_doc_comment_marker "!" @comment)
+[
+ (line_comment)
+ (block_comment)
+] @comment
; ---
; Extraneous
@@ -212,6 +194,10 @@
; Keywords
; -------
+(for_expression
+ "for" @keyword.control.repeat)
+(gen_block "gen" @keyword.control)
+
"in" @keyword.control
[
@@ -240,6 +226,10 @@
(type_cast_expression "as" @keyword.operator)
+((generic_type
+ type: (type_identifier) @keyword)
+ (#eq? @keyword "use"))
+
[
(crate)
(super)
@@ -257,10 +247,6 @@
"async"
] @keyword
-(for_expression
- "for" @keyword.control.repeat)
-(gen_block "gen" @keyword.control)
-
[
"struct"
"enum"
@@ -303,23 +289,6 @@
; Functions
; -------
-; highlight `baz` in `any_function(foo::bar::baz)` as function
-; This generically works for an unlimited number of path segments:
-;
-; - `f(foo::bar)`
-; - `f(foo::bar::baz)`
-; - `f(foo::bar::baz::quux)`
-;
-; We know that in the above examples, the last component of each path is a function
-; as the only other valid thing (following Rust naming conventions) would be a module at
-; that position, however you cannot pass modules as arguments
-(call_expression
- function: _
- arguments: (arguments
- (scoped_identifier
- path: _
- name: (identifier) @function)))
-
(call_expression
function: [
((identifier) @function)
@@ -452,7 +421,6 @@
(#eq? @special "derive")
)
-(token_repetition_pattern) @punctuation.delimiter
(token_repetition_pattern [")" "(" "$"] @punctuation.special)
(token_repetition_pattern "?" @operator)