Sublime Forum

Color highlighting from a .tmLanguage file

#1

I am currently developing a custom sublime tmLanguage file for bioinformatics related files. I have read the usual tutorials and am all set up with AAAPackageDevelopment. My first goal is to highlight nucleotides, which appear as strings containing [AaTtCcGgNnUu]. I would like to be able to specify my own scopes, and assign colors to them within my tmLanguage file.

Here is an example for the A base:

patterns:
- comment: Adenine
  match: "[Aa]+"
  name: constant.other.nucleotide.adenine

From what I can tell, .tmTheme files handle the assignment of actual color codes to scopes. I have found examples (https://github.com/hackerfriendly/ACTG) where the nucleotide highlighting was done by assigning existing scopes (ones that are defined in the default/currently loaded tmTheme file) to each base. I would like to have more control over this.

One obvious approach would be to include a .tmTheme file with my .tmLanguage file, but I would like to just add more theme rules to an existing theme, not completely overwrite a users existing theme.

I would love some advice or ideas on how to accomplish this,
Thanks!

0 Likes

#2

Not possible.

Or well, it is possible by “dirty hacking” via a plugin that inspects the color scheme used but definitely not something I would recommend in this case. Main reason is that you color scheme principles might easily clash with the user’s or the author of the color scheme the user is using, thus resulting in badly coordinated colors all over the place.

You should really either stick to default scope names or provide your own color scheme, along with a syntax-specific settings file that automatically tells ST to open said syntax with your color scheme. Can be problematic for bright vs. dark backgrounds though.

0 Likes