Sublime Forum

Importing variables from one syntax to another

#21

I thought that it was easy with your plugin but I need to know Python, and I don’t.I give up. Thanks for your help.

0 Likes

#22

As long as you’re only using macros from the built-in libraries (including extend), you shouldn’t need to write any Python code for what you’re trying to do.

0 Likes

#23

@ThomSmith
It works now (Build doesn’t work, but Build with works… Not sure exactly what’s the difference between them).

The result is not what I want though. I have almost 70 syntax files sharing many long lists of variables. I don’t want to add them to all files, I would like that ST uses them from a single file. I’m afraid ST doesn’t support this feature and even a plugin can’t do it.

As I can add a link to external contexts using a basic syntax I can reduce a lot of redundancy. Not the best way, but no choice I guess.

0 Likes

#24

I don’t want to add them to all files, I would like that ST uses them from a single file.

I’m not sure I understand the distinction.

Sublime doesn’t directly “use” sublime-syntax files; it compiles them into a binary representation. And I’m nearly certain that it resolves syntax imports (like scope:source.js) by simply copying all of the relevant rules from the other syntax. So at the level of the binary representation that Sublime actually uses, there is no sharing of code between syntaxes.

YAML Macros adds another layer – the sublime-syntax.yaml-macros representation. This makes the sublime-syntax an intermediate representation. I’ve put a lot of work into making that intermediate representation as similar as possible to the authored code in the yaml-macros file, but fundamentally the compiled sublime-syntax file isn’t meant to be the canonical human-editable representation of the syntax. So I don’t mind if the compiled sublime-syntax is messy or contains a lot of duplicate code as long as it doesn’t affect performance.

I’d like to help you accomplish what you want to do, including adding new capabilities to YAML Macros if it makes sense to do so. It sounds like YAML Macros isn’t meeting your needs perfectly, but I can’t tell exactly how. Maybe if you were to describe your application in more detail (70 syntax files is certainly a lot!), I could better understand what you need.

0 Likes