Sublime Forum

Add ability to asign syntax to file based on file path

#1

Currently there’s three ways a syntax is assigned to a file:
-via the extension defined in the syntax file.
-via matching the first line of the file with the first_line_match regex.
-via a Python script.

Now, the third method allows to do what the title says, the problem is that for indexing symbols and thus using the Go to feature, only the two first methods are relevant (you can’t force symbol indexing of closed files according to a given syntax with a python script, as far as I’m aware). And for cases when you have files with the same extension and no specific first line having different grammars depending on what folder they’re on, this means symbol indexing is non-operant.

Thus why I propose adding a new field to syntax definition: path_match: {{regex}}, which would apply a syntax to a file, included for symbol indexing, if the path to the file matches the regex. This would be a sensible generalisation fo the extensions keyword, adding more expressive power to it.

(alternatively, a

0 Likes