Grammar pattern with path


Hey there,

I’m currently developing a language pack for Atom and facing some issues. So I’ve got a specific question:

I’ve got different grammar files.cson with different ‘patterns’ and ‘fileTypes’. Several things are working correctly, but I want to get a specific thing: paths as a match or any other way of it.
I’d like to have:

  • all .rb files within the directory recipes/ -> means: ./recipes/*.rb

Is this possible? (Hopefully, I described it in a good way)

Best regards,


Not directly, but you can do it programatically.

Here’s how the grammar path is scored internally. Only the extension is actually looked at.

The grammar select package uses the following

The TextBuffer also has a method to change it. I couldn’t see it documented in the API, and I thinks it’s experimental. I would use the above method instead though.


Do you have any example for me? As i understand this, such a change has to be made directly within the js file and not the created package, right?


Any package can use any part of Atom’s API. It doesn’t matter whether the package is a language package or not.