0
votes

Is there any way to include the color highlighting rules in the tmLanguage file itself?

For those who aren't familiar with it, Pro*C is sort of this mutant hybrid love-child of SQL and C, and both syntaxes are present in the file. However, there are a few Pro*C specific keyword which start or stop a big long block of SQL inside of one.

What I would like to do, is have the Pro*C keywords be different colors than the C/SQL keywords, and for the SQL blocks to have a different background color, so that they stand out. In none of the common themes are there appropriate scopes to use for this, not that I can tell. So I can't just call the Pro*C keywords "keyword.source.some-differently-colored language" (they should really be keyword.source.pro-c anyway) or the blocks "text.whatever.another-color" (using meta.block.pro-c right now).

It would be useful if I could just include the colors for these elements in the same plist that defines the syntax. Is this possible in Sublime? What's the correct way to do this?

1
Have you looked through the Language Grammars chapter of the TextMate manual? You might find something helpful there.angerson
@ProtractorNinja I have. I think I have the language syntax part right, it's just getting it to show up with colors in Sublime. I'd like to be able to distribute a single file/bundle that does colors, without overriding the user's theme for everything else.John O
You need to edit your .tmTheme file to add additional scopes. Check out Neon.tmTheme for a (pretty nice, if I do say so myself) theme with a ton of additional scopes. BTW, the best way I've found to edit it is to use TextMate, then copy the theme to your ST2 folder.MattDMo
@MattDMo So if I put this up for others to use, they all have to manually edit their tmTheme?John O
Yeah, unfortunately. As @skuroda said, there isn't a way to extend themes with subsidiary files. You can always add an extra file to your distribution with suggested edits to the .tmTheme so people know how to take advantage of your new scopes.MattDMo

1 Answers

1
votes

As far as I understand it, you would have to modify the color scheme file to support what you want. Bundling the colors as part of the tmLanguage file doesn't make sense anyways. By doing that, you would basically be saying every user has to use your predefined colors, which I could imagine people wouldn't like. For example, let's say I have a white background, and you decide to make the text color white. It would look like there is nothing there.

I think the best route is to include sample "extension" of the color scheme file. Then allow the users to modify it themselves as they see fit. This would also let you use the standard naming conventions, so if they don't apply any new scopes, everything still looks okay. Of course, they can specify a more detailed scope in the scheme file to apply the proper text color/background.

What I think would be nice was if there was some way to simply extend a color scheme from a separate file, rather than needing to modify the original. Though that doesn't exist.