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.
To map a filetype to a new language, use the
file-types option. Specify the extension (without a dot) as a key, and the new default extension as the value.
For example, the
.hbs extension defaults to the
handlebars grammar. To change it to default to
html-htmlbars (installed separately), open your
config.cson (via the
Atom -> Config... menu) and add the following rule:
"*": # make sure to put all "file-types" options under the "*" key"file-types":"hbs": "text.html.htmlbars"
An extension matcher will be converted into a RegExp matcher. The example above is equivalent to the following:
To see all available grammars registered in your Atom instance, open the Developer Tools Console and execute the following:
.), a pipe (
|), a caret (
^) at the start, or a dollar (
$) at the end to identify RegExp matchers.
The RegExp is currently matched against the base name of the file, as opposed to the entire path.
For example, you can associate
source.cucumber.steps in your
config.cson as follows:
"*": # make sure to put all "file-types" options under the "*" key"file-types":"_steps\\.rb$": "source.cucumber.steps"
The longest match is given precedence. If there are multiple matches of equal length, then a warning is displayed and the "last" (alphabetically) match is used.
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
To get a list of all scope names registered in your Atom instance, open the Developer Tools Console and execute the following:
Here is a list of the scope names available by default in Atom v1.8.0:
You probably don't want to assign the same file type to multiple languages...
Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.