Sublime Forum

How To: syntax highlighting & custom scopes

#1

I’m trying to create custom syntax highlighting, and having troubles understanding how .sublime-syntax and theme files work together, when I’m adding my own scopes. I’ve seen that it is possible in other packages. I’ve read the official and unofficial documentation as well.
Currently I have a package folder (because I’m planning to add features later), and inside it a .sublime-syntax file. This works great, whatever custom scopes I assign – they picked up by Sublime Text immediately, I see it in the Scope Viewer.

Now the hard part – how do I style it? If I create a .tmTheme file, it doesn’t work. If I use predefined scope names, like markup., string. or whatever – it works as it should, but those don’t have the styling I need.

Looking into existing packages on github is no use, because there is no consistency at all, so I can’t infer anything from there.

Any help is much appreciated.

1 Like

Howto: assign custom color for custom scope
#2

if you have created a custom color scheme, you need to tell ST to use it - i.e. syntax specific or user preferences

0 Likes

#3

It says:

If you want to specify settings for a certain file type, for example, Python, you should place them in Packages/User/Python.sublime-settings.

But what if I want to ship it with my package? Is it the color_scheme property btw? I have the settings file in my package folder already, it doesn’t help.

syntax specific or user preferences

They are both under User folder, that’s what I mean.

0 Likes

#4

Generally a package should contain a syntax or a color scheme, but not both. Most users will have a preference for what colors they want to use, so trying to use standardized scope names in your syntax is essential. Then the user can pick from thousands of color schemes to style it just the way they like.

The docs at http://www.sublimetext.com/docs/3/scope_naming.html contain a list of fairly ubiquitous scope names that are generally highly supported. Trying to use some variant of those will be best for you and other users of the package.

2 Likes