vscode-cpptools
vscode-cpptools copied to clipboard
[Feature Request] Semantic highlight of each local variable with a different color
Feature Request
Hello!
I really like enhanced highlighting, but I've saw feature called semantic highlighting in the CLion which is basically highlights all the local variables with a different color, which makes it easier to distinguish.
I'm curios, is it possible to do it with intellisense?
If it is, maybe you can guide me a bit and I would glad to contribute.
As example I attach my project, as you can see, 3 variables initialized and all of them has different color.
Thanks!

I don't believe this can be implemented without additional support from VS Code: https://github.com/microsoft/vscode/issues
@Colengms correct me me if I'm mistaken.
highlights all the local variables with a different color
Hi @krupitskas . The C/C++ extension does return a distinct token for local variables. You can see how tokens (both syntactic tokens from VS Code and semantic tokens from the C/C++ extension) are associated with your code using the Developer: Inspect Editor Tokens and Scopes command, then clicking on a keyword in your source code.

If the theme you are using does not use a unique color for a token that you would like colored uniquely, you can override the colorization of that token in your local settings. Guidance on this is here and here
@Colengms Yeah, I was right about to add that scope info you provided. However, they're requesting a feature from VS Code that auto-rotates the color, similar to what VS Code does with braces.
The specific data we provide VS Code is
which VS Code would need to check to decide if colors should be rotated in that case (not sure if themes should opt-in to that color rotation and/or if there should be a user setting to override the theme colors).
Indeed, the auto-rotating of the color would require support from VS Code. @krupitskas , consider opening a feature request against VS Code for this.
similar to what VS Code does with braces.
Actually this is interesting, because this was a separate extension which did it. Now it's achieved, because VS code has integrated it, but still, I can take a look how brace color rotatation was implemented.
We could potentially implement this in the C/C++ extension using editor 'text decorations'. However, that's very inefficient. If instead VS Code were to handle the coloration for us and provide an API to allow us to group tokens for the same variable, that could potentially provide much better performance.
This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.
This feature request has received enough votes to be added to our backlog.