[TxMt] TextMate grammar help - stopping repository pattern includes overriding ?

Scott McGillivray fourlightson at hotmail.com
Thu Jan 17 14:54:59 UTC 2019


Hello

I am new to Textmate and grammars syntax but i want to fix a bug with a grammar used by GitHub for highlighting of SaltStack files. 

The grammar in question is this one ( https://github.com/saltstack/atom-salt/blob/master/grammars/yaml.cson ) and the problem is comments that span multiple lines don't get handled correctly so i fixed the regexp but the more i looked at the problem i don't think any comments are really being handled as the grammar expects because of an "include" that's overriding the local comment definition.

As i said, i'm no Textmate/Grammar expert but with some fumbling around i think the problem occurs due to a repository entry that calls:

      {
        'include': 'source.python'
      }

This external grammar file has its own agenda when it comes to comments and lines matching the "#" type pattern. I think this included grammar is taking priority over the patterns/captures defined in the above .cson file. I believe it might be this pattern ( https://github.com/textmate/python.tmbundle/blob/master/Syntaxes/Python.tmLanguage#L1519 ). 

If i comment/delete the  'include': 'source.python' from the "jinja-control" repository then my regexp change works and comments look as expected.. but obviously I've crippled the other highlighting brought with the python include.

So at this point i'm stuck. I have no idea how the order or precedence works and how i should resolve this conflict ? 

Can someone explain please why the include is doing this and whats the way for me to ensure my local definitions to be enforced ? I tried moving my pattern to the top of the .cson, tried to make the regexp more explicit and increase the name depth in case any of those were the magic but no luck.

thank you.


More information about the textmate mailing list