I have two syntax versions: v1 and v2. Each is in its own .sublime-syntax file for ease of editing/comparison etc.
They are differentiated by an optional “shebang”/first line indicator, but since they use the same file extension, and file extensions have a higher priority vs. first_line_match ST header, I can’t directly use this header property to differentiate them.
Now, I’ve found an alternative: using a third “loader” syntax definition (let’s call it v1or2) that will have its main rules matching shebang and setting whatever version matches, and if nothing matches, sets the newer v2.
But there are a few issues:
-
how to prioritize a given file to make it parse the same extension first? So far it seems that whichever is named alphabetically last wins. Is there an explicit way?
-
How to replace the bottom-right indicator with whatever the new v1 or v2 is set? I’ve made the
v1or2syntaxhidden: true, so it disappears from the command palette or the bottom-right menu, but it’s still shown as the name of the active syntax -
Since each syntax definition has a default
scope, I now always have dupe scope: fromv1or2and fromv1orv2. Is there a way, whensetting the scope, replace the original main?
Basically, I’m looking for a way to completely eliminate this loader syntax or have an alternative way for the original v1 or v2 files to be selected within the same extension based on the first line
Or is this only possible via a plugin?