Sublime Forum

Retain color in comments (apply color transformation function to a batch of existing rules)

#1

In a color scheme you can have custom color variables for various elements, for example

{"name":"Variable"	,"foreground":["var(blue_beg)","var(purple_end)"]	,"scope":"variable, meta.qualified-name"},
{"name":"Keyword" 	,"foreground":"var(red10)"                       	,"scope":"keyword"},

I also have a comment scope that kills all the colors

{"name":"Comment"	, "foreground":"var(black3)"	,"scope":"comment"                                              },

However, what I’d like to do is instead of making all the colors black is to retain the colors, but make them faint to differentiate from non-commented variant. This is helpful for some comment types that by design comment out valid blocks of code unlike e.g., // or /* comments that don’t care about what comes next

There is this very useful function saturation that does exactly that, but then it requires me to apply it individually to every scope like:

{"name":"Keyword"        	,"foreground":      "var(red10)"          	,"scope":                "keyword"},
{"name":"Keyword Comment"	,"foreground":"color(var(red10) s(- 80%))"	,"scope":"special-comment keyword"},

Instead of this error-prone copy&paste I’d like to apply to each scope special-comment * (* signifying any additional scope) to apply a saturation function to whatever the color * scope has

0 Likes