facelessuser / ApplySyntax

Syntax detector for Sublime Text
https://facelessuser.github.io/ApplySyntax/
343 stars 48 forks source link

Override XML rule for tmPreferences #125

Closed michaelblyons closed 5 years ago

michaelblyons commented 5 years ago

I have the venerable PackageDev package installed, which has some specialty language definitions. Unfortunately, ApplySyntax overrides one of them (the one for .tmPreferences files) and sets it to XML with the default rules. I'd like to override it back in my User Settings' rules, but I can't seem to get it to work. I've tried these things so far:

    syntaxes: [
        // If you have PackageDev installed, use it for tmPreferences files.
        // If not, fall back to XML.
        {
            "syntax": [
                "PackageDev/TextMate Preferences/TextMate Preferences",
                "XML/XML",
            ],
            "extensions": ["tmPreferences"],
        },
        {
            "syntax": [
                "PackageDev/TextMate Preferences (PList / XML)",
                "XML/XML",
            ],
            "extensions": ["tmPreferences"],
        },
        ...
    ]

I'm curious why you even need the first_line rule in the default_syntaxes. It basically duplicates the first line matching already in XML.sublime-syntax.

facelessuser commented 5 years ago

Pretty sure I inherited that rule when I took over ApplySyntax, but I could be wrong. I'll take a look when I get a chance and get back to you. I need to refresh on overrides.

michaelblyons commented 5 years ago

Turns out, none of these work:

        {
            // If you have PackageDev installed, use it for tmPreference files
            "syntax": [
                "PackageDev/TextMate Preferences",
                "PackageDev/TextMate Preferences (PList / XML)",
                "PackageDev/TextMate Preferences/TextMate Preferences",
                "TextMate Preferences",
                "TextMate Preferences (PList / XML)",
                "TextMate Preferences/TextMate Preferences",
                "XML/XML",
            ],
            "extensions": ["tmPreferences"],
        },
facelessuser commented 5 years ago

I'm not sure how easy it is to override. User rules may just append, I'll have to check. Just haven't had a chance yet.

michaelblyons commented 5 years ago

User rules may just append

Nuts, you're right. I am very opinionated that the order should be switched so user rules come first.

https://github.com/facelessuser/ApplySyntax/blob/0faad8ee6ec13b15c74375b5198137a804054cd5/ApplySyntax.py#L226-L227

facelessuser commented 5 years ago

I didn't come up with the current design. I'm not the original author. I think the original idea was that the default rules were universally desired.

I mean we could add a package dev rule. We could also overhaul the current rule system to be more flexible.