Would there be a way to get all the variable names colored based on a hash of their name?
Semantic Variable Name Highlighting
I guess this is possible using a combination of a custom grammar matching all words with the same scope and an additional package that retrieve these scopes after parsing in order to affect colors based on their content.
Actually, I don’t think it even needs to be a custom grammar. I mean, your color highlight package makes all kinds of strings different colors and it doesn’t use a custom grammar, does it?
True, but it was more because I couldn’t find how to easily hack into the current grammar, but yeah, obviously it doesn’t require a new grammar.
My fear is that using the same kind of implementation I use for colors will be quite counter productive for variables:
- There’s generally much more variables in a basic code file than colors in a sass or less palette file.
- Markers position updates are sometime delayed and I don’t know how to solve that. With hundreds of markers in a file it could becore quite a mess.
- You’ll have to implement yourself occlusion culling for these markers (I haven’t implemented it yet, but I should).
This discussion is quite interesting but I’m bit short of time here :).
Have a nice week-end
Semantic highlighting
Honestly, I wouldn’t even worry about the scope of the variable. I would just color the names of the variables based on a color hash. If the variable i
has the same color in different scopes I don’t see that as a readability issue.
This post can be closed because of this: https://github.com/p-e-w/language-javascript-semantic