Home

Awesome

file-types package

Installs! Version! License

Specify additional file types for languages.

Note: A subset of this functionality is now available directly in Atom--see Customizing Language Recognition in the Flight Manual.

Matchers

To map a filetype to a different language, use the file-types option in your config.json (via the Atom -> Config... menu). Specify a pattern to match for the key (in bash-like glob format) and the new scope name for the value.

For example, the .hbs extension defaults to the handlebars grammar. To override this to the text.html.htmlbars grammar (provided by the separately installable html-htmlbars), add the following rule to your config.cson:

"*":  # Be sure to put "file-types" under the "*" key
  "file-types":
    "*.hbs": "text.html.htmlbars"

Use the double-star-and-slash notation (** and /) to match against the whole path.

"*":
  "file-types":
    "**/app/tmpl/*.hbs": "text.html.htmlbars"
    "**/text_files/*": "text.plain"

Precedence

The longest glob is given precedence.

For example, with the following settings, all three globs end in .liquid.

"*":
  "file-types":
    "*.css.liquid": "source.css"
    "*.liquid": "text.html.basic"
    "*.scss.liquid": "source.css.scss"

Both *.liquid and *.css.liquid would match a file named super_awesome_file.css.liquid; however, since *.css.liquid is longest, it wins and the source.css scope name would be used.

This is usually not a problem unless multiple globs of equal length match the filename. When that happens, a warning is displayed and the scope name associated with the "alphabetically last" glob is used.

Consider the following settings:

"*":
  "file-types":
    "*_spec.rb": "source.ruby.rspec"
    "*_sp?c.rb": "text.plain"

Both of these would match a file named super_controller_spec.rb; however, *_spec.rb would win because when sorted alphabetically, it comes last (i.e., "*_sp?c.rb" < "*_spec.rb").

Scope Names

The scope name for a grammar can be found in the settings for the corresponding language package. For example, the scope name for CoffeeScript's grammar (as provided by the language-coffee-script package) is source.coffee.

To get a list of all scope names registered in your Atom instance, open the Developer Tools Console and execute the following:

console.log(atom.grammars.getGrammars().map(g => g.scopeName).sort().join('\n'))

Here is a list of the scope names available by default in Atom v1.8.0:

Caveats

You probably don't want to assign the same file type to multiple languages...