Bundling stylesheets in language package


Hi all,

I was wondering whether it would not make more sense to bundle some stylesheets directly within the language package.
Just had a very quick look for now but my understanding is that language packages match patterns to CSS class selectors.


    'match': '\\b(asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void)\\b'
    'name': 'storage.type.c'

But then syntax themes must know all of the class selector names used in the language packages to work properly.

So if one wants to come up with its own language package with its own naming convention, he also has to do a syntax theme for it.
That’s why I would find it better to include stylesheets within the language packages.

Or have I missed something ?

Thanks a lot !


This is something I was wondering about as well. But it creates some problems. For example when you specify that some keywords should become pink. This may suite your color choices, but others may disagree.
It would be nice to mix and merge multiple style sheets, such that you can check if you want to apply the language specific styles. It would also help to standardise the naming of the variable colouring.


One shouldn’t include stylesheets in a language package. When you’re writing a language package, you don’t know if the user has a dark theme installed or a light theme installed. You don’t know if the colors you pick will even be visible in the user’s UI. This is why the separation between language package and syntax theme exists … the language package just handles identifying the “scope” of the tokens. The syntax theme determines what styles to apply to which scopes.

Because scopes are based on CSS classes … I can simply put .variable in my syntax theme and BAM variable colors are standardized across all languages.

How to override syntax higlight (One Dark) in syntax-higlight-theme

The point was slightly different. Assume you have a language where you have some hardware description language and you add modifiers to a variable declaration. This might look like this:
out register int<18> variable;
Now, all of them are keywords or modifier, but register is a more important one than for example in. So in the language grammar I say that this is: storage.modifier.register.pshdl. Now chances are good that no style-sheet will have a special definition for exactly that. So the user would need to get to modify each style-sheet he tries to account for that. And he would have to do that manually.
My vision would be that grammar designer could generate a style-sheet for those additional declarations. So the user could go to the settings and check a checkbox that he would like to (partially) import some of those additional declarations.


Except you still haven’t solved the issue of whether the end-user is using a light or dark syntax. You haven’t solved whether or not the color choice would even be visible on their scheme. The color choice could decrease contrast rather than highlight the register modifier in your example.

If you really want to design the color scheme for your language, you can always create additional packages called language-foo-light-styles or something. People who want it can install it separately from your grammar package.


I kind of like the idea. But unfortunately you can’t set a theme for a specific file extension, can you?
That would be really cool to say: For PSHDL files, always use the pshdl-language styling. Or is there some way to package a style?


You can add styles to any package because some packages offer UI. For an example, see my bug-report package.

You can’t style a specific extension, but you can add styles by grammar. You can take a look at the data-grammar attribute of the atom-text-editor element to see what grammar is attached to it and style based on that.