Strider
Strider

Reputation: 402

Sublime Text / TextMate scope parameter

Sublime Text (and TextMate) language and color-theme files interacts via scope parameter. It is a dotted name, that might be useful in styling (and other cases).

For instance (in XML language file): <string>support.constant.js</string>

How can one style it (besides strict equality)? Can one style this certain item via support.constant or constant.js or js? Does this parameter support hierarchy, and if does in which way (left-to-right or in reverse)? Does styling cascades like in CSS?

I have deep interest in creating flexible color theme that will support not only certain languages, but all, gracefully degrade in case of no special support. For this I need to know how scopes work. It will allow to style common (for many languages) structures, like function, constant, variable, keyword etc.

Upvotes: 0

Views: 891

Answers (2)

tushortz
tushortz

Reputation: 5125

You can also have a look at Scopes which includes different scopes for up to 160 languages. You will find it handy

Upvotes: 2

MattDMo
MattDMo

Reputation: 102922

I have a quite complex color scheme over at Github that you are more than welcome to take a look at for ideas. Basically, scopes work from left to right - to highlight support.constant.js, you could use support or support.constant or support.constant.js, but not constant or constant.js or js. Within a JavaScript file, everything is scoped as source.js, so if you just wanted to highlight all support scopes in a .js file, you would use source.js support.

For theming, I find the ScopeAlways plugin very helpful, as it shows the full scope in the status bar at all times. Another great resource is ColorSchemeEditor, a GUI for editing color schemes.

Upvotes: 1

Related Questions