queries(rust): add scope for mutable variables#14353
queries(rust): add scope for mutable variables#14353nik-rev wants to merge 2 commits intohelix-editor:masterfrom
Conversation
test file:
```rs
fn foo() {
let mut a = 100;
}
```
split up helix-editor#13932
runtime/queries/rust/locals.scm
Outdated
| [ | ||
| (let_declaration | ||
| (mutable_specifier) | ||
| pattern: (identifier) @local.definition.variable.mutable @variable.mutable) |
There was a problem hiding this comment.
Both here and #14352 you should only write local.definition.*, local.scope, local.reference or throwaway captures in the locals.scm file, not highlight captures. I think it's necessary to make some highlights work currently but it's a bug in locals if it's required
There was a problem hiding this comment.
I'm curious - why is it a bug?
anyway, I have "fixed" this by just duplicating the query. I wish there was a more elegant solution
There was a problem hiding this comment.
The locals.scm queries should be separate from highlights and ideally have separate precedence too, so you could hypothetically say
; All parameters are variable.parameter
(parameter) @local.definition.variable.parameter
; Except builtins
((parameter) @_self (#eq? @_self "self"))Ideally you should also not need to duplicate the highlights between locals.scm and highlights.scm: the locals should take precedence when they match. This needs a bit of work in tree-house to get right.
test file:
split up #13932