Sublime Forum

Sequentially match the deepest scope in a color scheme

#1

The standard scopes being used in the core requires meta scopes to stack, this is problematic if you try to give different colors for e.g. function/class punctuation, because in languages like javascript, you can declare a class inside a function and that would make the class having the meta.function scope too.

A simple example:

class MyClass {
  myMethod() {
  }
}

The scopes for opening brace for that method is:

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

The proposed solution would be to have some sort of operator to match the scopes sequentially and from the bottom up, so that you could do something like:

Match the deepest element as punctuation.section
Directly preceded by meta.block
Directly preceded by meta.function

And in the case of classes:

Match the deepest element as punctuation.section
Directly preceded by meta.block
Directly preceded by meta.class
0 Likes

[RFC] Specific scopes for punctuations
[RFC] Specific scopes for punctuations
#2

It looks like the current behavior for sublime scope scoring is actually a bug, and, if fixed would make the suggestion unnecessary.

1 Like