queries: Highlight mutable variables in Rust

pull/13932/head
Nik Revenco 2025-07-14 02:28:50 +01:00
parent e610e7dd80
commit a2f219968a
3 changed files with 16 additions and 3 deletions

View File

@ -179,6 +179,7 @@ We use a similar set of scopes as
- `variable` - Variables - `variable` - Variables
- `builtin` - Reserved language variables (`self`, `this`, `super`, etc.) - `builtin` - Reserved language variables (`self`, `this`, `super`, etc.)
- `parameter` - Function parameters - `parameter` - Function parameters
- `mutable` - Mutable variables (e.g. marked with `mut` in Rust)
- `other` - `other`
- `member` - Fields of composite data types (e.g. structs, unions) - `member` - Fields of composite data types (e.g. structs, unions)
- `private` - Private fields that use a unique syntax (currently just ECMAScript-based languages) - `private` - Private fields that use a unique syntax (currently just ECMAScript-based languages)

View File

@ -289,8 +289,6 @@
"dyn" "dyn"
] @keyword.storage.modifier ] @keyword.storage.modifier
; TODO: variable.mut to highlight mutable identifiers via locals.scm
; --- ; ---
; Remaining Paths ; Remaining Paths
; --- ; ---

View File

@ -12,7 +12,7 @@
(block) (block)
] @local.scope ] @local.scope
; Definitions ; Parameters
(parameter (parameter
pattern: [ pattern: [
@ -39,5 +39,19 @@
) )
]) ])
; Mutable variables
[
(let_declaration
(mutable_specifier)
pattern: (identifier) @local.definition.variable.mutable @variable.mutable)
(parameter
(mutable_specifier)
pattern: (identifier) @local.definition.variable.mutable @variable.mutable)
(mut_pattern
(mutable_specifier)
(identifier) @local.definition.variable.mutable @variable.mutable)
]
; References ; References
(identifier) @local.reference (identifier) @local.reference