Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: add highlight scope for type parameters #8660

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ We use a similar set of scopes as

- `type` - Types
- `builtin` - Primitive types provided by the language (`int`, `usize`)
- `parameter` - Generic type parameters (`T`)
- `enum`
- `variant`
- `constructor`
Expand Down
7 changes: 7 additions & 0 deletions runtime/queries/rust/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
; Types
; -------

(type_parameters
(type_identifier) @type.parameter)
(constrained_type_parameter
left: (type_identifier) @type.parameter)
(optional_type_parameter
name: (type_identifier) @type.parameter)

; ---
; Primitives
; ---
Expand Down
15 changes: 14 additions & 1 deletion runtime/queries/rust/locals.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

[
(function_item)
(struct_item)
(enum_item)
(union_item)
(type_item)
(trait_item)
(impl_item)
(closure_expression)
(block)
] @local.scope
Expand All @@ -11,8 +17,15 @@
(parameter
(identifier) @local.definition)

(type_parameters
(type_identifier) @local.definition)
(constrained_type_parameter
left: (type_identifier) @local.definition)
(optional_type_parameter
name: (type_identifier) @local.definition)

(closure_parameters (identifier) @local.definition)

; References
(identifier) @local.reference

(type_identifier) @local.reference
Loading