How do I handle a grammar with the same file extension?


#1

Suppose I have a grammar that uses the same extension as another grammar, is there a best practice for dealing with this? My use case is that I’ve created a grammar for PL/SQL (Oracles procedural database language) based on a TextMate bundle, and was thinking that code files with the sql extension shouldn’t always map to PL/SQL.

Just trialling with a few: language-sql-mysql, language-oracle and language-tsql - and the grammar seems always to map to PL/SQL (the grammar I created) with a single file with the extension .sql no matter which order I install the packages in.

The contents of the file was:

select *
from people

Should I be looking for keywords in other languages and tell my package, “don’t use this grammar”, where they aren’t also keywords in PL/SQL? (not sure if that is even possible) Or should I only be finding patterns/keywords that do exist for PL/SQL to tell it to use the grammar in that case?

The docs specify:

If you load up a file, Atom does a little work to try to figure out what type of file it is. Largely this is accomplished by looking at its file extension (.md is generally a Markdown file, etc), though sometimes it has to inspect the content a bit to figure it out if it’s ambiguous.

Trying to find some examples, the extension tpl which is matched to the packages language-html and language-smarty-php. Looking in language-html I can see it has a spec specified for when that grammar should be matched, whereas language-smarty-php has no spec, so I presume it falls back to this package when the html one doesn’t match.

Is there any other examples where this same situation may be present?