Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Injected grammar priority #59

Closed
tomedunn opened this issue Sep 12, 2015 · 5 comments · Fixed by #78
Closed

Injected grammar priority #59

tomedunn opened this issue Sep 12, 2015 · 5 comments · Fixed by #78

Comments

@tomedunn
Copy link

Currently grammar can be injected into existing rules using the injections region as in

'name': 'Grammar Test'
'scopeName': 'source.grammar-test'
'fileTypes': ['test']
'injections':
  'source.grammar-test':
    'patterns':[
      {
        'name': 'invalid.error.grammar-test'
        'begin': '!'
        'end': '\\n'
      }
    ]
'patterns': [
  {
    'name': 'comment.line.grammar-test'
    'begin': '!'
    'end': '\\n'
  }
]

Now, the above grammar won't do anything because grammar rules added using the injections method are added to the end of the rule stack which gives them the lower priority of all of the rules. However, from what I understand about the Textmate grammar engine, one should be able to modify the scope selector from 'source.grammar-test': to 'L:source.grammar-test': to add it to the start of the stack giving it the highest priority (I believe the L: means left, I've seen both L: and R:). Sadly, adding either of these prefixes appears to have no effect. Removing the original comment grammar one can verify the injected grammar is indeed added to the rules with or without the prefix, it just don't have any effect on the priority. Am I interpreting this correctly? Is there a way of altering the injected grammars priority?

@nebularg
Copy link

Adding framework/api specific scopes without having to reimplement all of the parent grammars after yours would be great. Any plans on adding this?

@Stanzilla
Copy link

@nathansobo is that something the team would consider? Being able to enhance existing language-* packs with specific scopes instead of having to fork (and always maintain that fork) and then add your stuff is a bit annoying.

@nathansobo
Copy link
Contributor

I would definitely consider it but don't have the bandwidth to change priorities and add this to first-mate. Is there a PR open for review?

@Stanzilla
Copy link

@nathansobo sadly not, was mainly pinging you because you had the most (recent) activity on the project :)

@50Wliu
Copy link
Contributor

50Wliu commented Oct 3, 2016

Got this working for injectionSelector grammars. Hopefully I can finish up normal injections as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants