add highlight scope for type parameters (#8660)

* rust: add highlight scope for type parameters

* handle optional type parameters
pull/8712/head
Joey Hain 1 year ago committed by GitHub
parent ae6a0a9cfd
commit 70bbbd7d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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`

@ -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
; ---

@ -2,6 +2,12 @@
[
(function_item)
(struct_item)
(enum_item)
(union_item)
(type_item)
(trait_item)
(impl_item)
(closure_expression)
(block)
] @local.scope
@ -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…
Cancel
Save