Open Seltyk opened 1 year ago
We don't host the textmate grammar for rust, that is upstreamed in VSCode. The rust extension there (which solely provides said grammar) would need to set appropriate balancedBracketScopes
, something like
"balancedBracketScopes": [
"punctuation.brackets.angle.rust",
"punctuation.brackets.square.rust",
"punctuation.brackets.curly.rust",
"punctuation.brackets.round.rust",
"punctuation.brackets.attribute.rust"
]
Ideally the whole thing would work with semantic tokens as thats what rust-analyzer emits but VSCode doesn't allow that, neither does it respect semantic token to textmate token fallback to work with it. So there isn't really anything to do from our side here.
Edit: Actually nevermind, the rust extension would need to do what typescript does here, explicitly listing wrong scopes https://github.com/microsoft/vscode/blob/adf93c270acf019a7ab0385ff5d9a66eba7aafc3/extensions/typescript-basics/package.json#L69-L76 which is incompatible with macros unfortunately. So this is blocked on https://github.com/microsoft/vscode/issues/176644
VS Code's built-in TypeScript syntax highlighting supports rainbow brackets for type generics, as evidenced by this repro.
Admittedly, only the left angle brackets are rainbowified on my system, though I have seen correct coloring in real code.
rust-analyzer, does not rainbowify angle brackets, as evidenced by this repro
Clearly, it is possible to have rainbow type generics, and I would like to see that in future. It would make reading complex types (such as session types for network communication protocols) easier.
Of course, this
Test
type is a bit silly, andcargo clippy
does warn about complex types, suggesting layered aliasing to make them easier to read and understand. However, the added readability of rainbow brackets should not be ignored.