Unnamed repository; edit this file 'description' to name the repository.
queries: Improve Rust const generic and '_' type highlighting
You may pass constants as type arguments the const generics feature.
This is used in spellbook for example as a poor man's enum, for example
`self.strip_suffix_only::<FULL_WORD>(word, hidden_homonym)`. With this
change that `FULL_WORD` part is highlighted as a constant instead of
a type.
This change also highlight the underscore in type placeholders - this
is similar to the highlighting done for bindings in Elixir or Erlang
for example. In `Vec<_>` the underscore is highlighted the same as a
comment.
| -rw-r--r-- | runtime/queries/rust/highlights.scm | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/queries/rust/highlights.scm b/runtime/queries/rust/highlights.scm index 66a21ffb..fb363599 100644 --- a/runtime/queries/rust/highlights.scm +++ b/runtime/queries/rust/highlights.scm @@ -95,8 +95,10 @@ left: (type_identifier) @type.parameter) (optional_type_parameter name: (type_identifier) @type.parameter) -(type_arguments - (type_identifier)) +((type_arguments (type_identifier) @constant) + (#match? @constant "^[A-Z_]+$")) +((type_arguments (type_identifier) @comment.unused) + (#eq? @comment.unused "_")) ; --- ; Primitives |