atom / first-mate

TextMate helpers
http://atom.github.io/first-mate
MIT License
91 stars 57 forks source link

Extending injected grammars #40

Open Ingramz opened 9 years ago

Ingramz commented 9 years ago

I was looking into language-blade grammar (https://github.com/jawee/language-blade/blob/master/grammars/blade.cson). To my surprise it features a PHP grammar of its own. Keeping this in sync with the language-php grammar could work, however I was thinking of a more novel solution so that there wouldn't be duplicate grammars.

The way how PHP grammar works with HTML grammar - through injection seems like a prefect way of solving this since blade syntax lives on the same level as <?php ?> tags inside the HTML document.

So I thought, why not write our own injections for the PHP grammar, but including the PHP grammar does not seem to work as expected. But the issue I ran into is when referencing the PHP grammar.

'scopeName': 'text.html.php.blade'
'name': 'Blade'
'fileTypes': [
  'blade.php'
]
'patterns': [
  {
    'include': 'text.html.php'
  }
]

With that grammar, only the HTML parts get highlighted. Is this intentional?

lee-dohm commented 9 years ago

See my post on Discuss about how the PHP grammar is designed:

https://discuss.atom.io/t/php-snippets-not-working/15321/8?u=leedohm

A PHP file is assumed to be an HTML template and has two major scopes, text.html.php for the HTML portions and source.php for the PHP portions. You may want to include both sets of patterns.

Ingramz commented 9 years ago

Tried one pattern at a time and also both, I can't seem to reach PHP-s parts with that grammar. If I add something else, for instance source.c, then that works.