Skip to content

Limited syntax highlighting version override based on shebang #5093

@eugenesvk

Description

@eugenesvk

Problem description

There are different syntax versions for the same file extension, with the syntax version signaled in the first line, so I can differentiate between v1 and v2 by using the first_line_match
However, I can't do anything with this information since for defined extensions this first_line_match variable is ignored and a random syntax definition wins (the one that's loaded later) even if the shebang doesn't match, so it ends up with incorrect syntax highlights

Preferred solution

(the solution should work only within the same file extension to prevent the overhead of parsing shebangs for all the files)
If there are multiple syntax definitions for the same file extension, there should be an option to prioritize the one that matches the shebang

Alternatives

I thought of deleting the file extension variable in the syntax definition , but then v1 doesn't require any shebangs, so will match all the files if I add a .* or something, which is obviously undesirable

You could also change extensions, but that's rather cumbersome (especially for minor version syntax changes)

Otherwise I don' t know how to fix it currently

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions