You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+22-23Lines changed: 22 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,47 +8,46 @@ Specify additional file types for languages.
8
8
9
9
_Note:_ A subset of this functionality is now available directly in Atom--see [Customizing Language Recognition](http://flight-manual.atom.io/using-atom/sections/basic-customization/#customizing-language-recognition) in the Flight Manual.
10
10
11
-
## Extension Matchers
11
+
# Matchers
12
12
13
-
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.
13
+
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.
14
14
15
-
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:
15
+
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`:
16
16
17
17
```cson
18
-
"*":# make sure to put all "file-types" options under the "*" key
18
+
"*":# Be sure to put "file-types" under the "*" key
19
19
"file-types":
20
-
"hbs":"text.html.htmlbars"
20
+
"*.hbs":"text.html.htmlbars"
21
21
```
22
22
23
-
An extension matcher will be converted into a RegExp matcher. The example above is equivalent to the following:
23
+
## Precedence
24
24
25
-
```coffee
26
-
"*":
27
-
"file-types":
28
-
"\\.hbs$":"text.html.htmlbars"
29
-
```
25
+
The longest glob is given precedence.
30
26
31
-
To see all available grammars registered in your Atom instance, open the Developer Tools Console and execute the following:
27
+
For example, with the following settings, all three globs end in `.liquid`.
You can match with regular expressions, too. Most JavaScript regular expressions should work; but, the system looks for a dot (`.`), a pipe (`|`), a caret (`^`) at the start, or a dollar (`$`) at the end to identify RegExp matchers.
37
+
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.
40
38
41
-
The RegExp is currently matched against the base name of the file, as opposed to the entire path.
39
+
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.
42
40
43
-
For example, you can associate `/.*_steps\.rb$/` with `source.cucumber.steps` in your `config.cson` as follows:
41
+
Consider the following settings:
44
42
45
43
```cson
46
-
"*":# make sure to put all "file-types" options under the "*" key
44
+
"*":
47
45
"file-types":
48
-
"_steps\\.rb$":"source.cucumber.steps"
46
+
"*_spec.rb":"source.ruby.rspec"
47
+
"*_sp?c.rb":"text.plain"
49
48
```
50
49
51
-
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.
50
+
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"`).
52
51
53
52
# Scope Names
54
53
@@ -57,7 +56,7 @@ The scope name for a grammar can be found in the settings for the corresponding
57
56
To get a list of all scope names registered in your Atom instance, open the Developer Tools Console and execute the following:
0 commit comments