Sublime Forum

Color scheme scope specificity

#1

While normalizing the scopes for my color scheme, I had this sittuation:

If I make the rules for the function punctuation more specific, the class {} also changes color because I basically have:

meta.class
meta.block
punctuation.section.block.begin/end

meta.function
meta.block
punctuation.section.block.begin/end

As the meta scopes stack and the rules have similar weight, there’s no way to target one or another. Is there a solution other than waiting for sublime to support a > operator similar to CSS?

0 Likes

#3

In that example, the scopes for the class body braces are:

source.js.fjsx15 
meta.function.js.fjsx15 
meta.class.js.fjsx15 
meta.block.js.fjsx15 
punctuation.section.block.begin.js.fjsx15

The method braces are:

source.js.fjsx15 
meta.function.js.fjsx15 
meta.class.js.fjsx15 
meta.block.js.fjsx15 
meta.function.js.fjsx15 
meta.block.js.fjsx15 
punctuation.section.block.begin.js.fjsx15

I want to give a different color to the class and function braces, but as the method is inside a class, it inherits the class’s meta scope, and thus the rules conflict.

2 Likes

[RFC] Specific scopes for punctuations
#4

I was able to do it by adding a bunch of specific rules, the problem is that this solution doesn’t work for all levels, every time I have a function or class inside a function, I need even more specific rules.

Unfortunately I believe that the only real solution would be to have a way to specify in the color scheme:

Select the deepest scope punctuation.section.group
directly preceded by meta.group preceded by
directly preceded by meta.function

And for classes:

Select the deepest scope punctuation.section.group
directly preceded by meta.group preceded by
directly preceded by meta.class

Which would serve as a general rule and work without caring how deep the function/class is in the code.

1 Like

[RFC] Specific scopes for punctuations