Sublime Forum

[Solved] How to override a syntax scope when there is another X scope present?

#1

How to override a syntax scope when there is another X scope present?

There is this scopes defined for the word defined on the preprocessor scope, form the default C++ Syntax file.

meta.preprocessor.c++
keyword.control.c++

And on my syntax file, want to override the scope keyword.control when the scope meta.preprocessor is also defined.
On my settings files, there is this trick for the spellchecking overriding:

"spelling_selector": "source string.quoted - punctuation - meta.preprocessor.include, source comment",

It would only allow the spell checking when the scope punctuation and meta.preprocessor.include are not defined.
Now I want to do the same on my theme file:

    <dict>
        <key>name</key>
        <string>Preprocessor</string>
        <key>scope</key>
        <string>preprocessor, meta.preprocessor - keyword.control</string>
        <key>settings</key>
        <dict>
            <key>fontStyle</key>
            <string>unbold</string>
            <key>foreground</key>
            <string>#804000</string>
        </dict>
    </dict>

But it is not working.

0 Likes

#2

I found the solution while writing this question. The problem is, I was using the - operator on the wrong scope definition.
I should do it on the keyword.control, instead of in meta.preprocessor:

    <dict>
        <key>name</key>
        <string>Keyword Common</string>
        <key>scope</key>
        <string>keyword.common, keyword.control - meta.preprocessor</string>
        <key>settings</key>
        <dict>
            <key>fontStyle</key>
            <string>bold</string>
            <key>foreground</key>
            <string>#0000FF</string>
        </dict>
    </dict>
0 Likes