@@ -10,20 +10,46 @@ https://github.com/microsoft/vscode-textmate/blob/main/src/rule.ts#L389
1010## Root
1111` { ... } `
1212The JSON object containing your grammar.
13- It is required along with [ patterns] ( #patterns ) and [ scopeName] ( #scopename )
14- Valid VSCode TextMate rules:
13+ It is required along with [ scopeName] ( #scopename )
14+
15+ Valid [ VSCode-TextMate] ( https://github.com/microsoft/vscode-textmate ) [ rules] ( https://github.com/microsoft/vscode-textmate/blob/main/src/rawGrammar.ts#L8-L18 ) :
1516* [ scopeName] ( #scopename )
1617* [ injections] ( #injections )
1718* [ injectionSelector] ( #injectionselector )
1819* [ patterns] ( #patterns )
1920* [ repository] ( #repository )
2021
21- Valid TextMate 2.0 rules: (ignored by VSCode TextMate)
22+ Valid [ TextMate 2.0] ( https://github.com/textmate/textmate ) rules:
2223* [ name] ( #name_display )
24+ * [ scopeName] ( #scopename )
2325* [ fileTypes] ( #filetypes )
2426* [ firstLineMatch] ( #firstlinematch )
2527* [ foldingStartMarker] ( #foldingstartmarker )
2628* [ foldingStopMarker] ( #foldingstopmarker )
29+ * [ injections] ( #injections )
30+ * [ injectionSelector] ( #injectionselector )
31+ * [ patterns] ( #patterns )
32+ * [ repository] ( #repository )
33+
34+ Valid [ shiki] ( https://github.com/shikijs/shiki ) [ rules] ( https://github.com/shikijs/shiki/blob/main/packages/types/src/langs.ts#L12-L41 ) :
35+ * [ name] ( #name_display )
36+ * [ scopeName] ( #scopeName )
37+ * [ displayName] ( #name_display )
38+ * ` aliases `
39+ * [ embeddedLangs] ( README.md#embedded-languages )
40+ * [ embeddedLangsLazy] ( README.md#embedded-languages )
41+ * [ balancedBracketSelectors] ( README.md#embedded-languages )
42+ * [ unbalancedBracketSelectors] ( README.md#embedded-languages )
43+ * [ foldingStopMarker] ( #foldingstopmarker )
44+ * [ foldingStartMarker] ( #foldingstartmarker )
45+ * [ injectTo] ( injections.md#injectionselector )
46+ * [ fileTypes] ( #filetypes )
47+ * [ firstLineMatch] ( #firstlinematch )
48+ * [ injections] ( #injections )
49+ * [ injectionSelector] ( #injectionselector )
50+ * [ patterns] ( #patterns )
51+ * [ repository] ( #repository )
52+
2753
2854Other rules: (ignored by VSCode/TextMate)
2955* [ information_for_contributors] ( #information_for_contributors )
@@ -51,7 +77,7 @@ For example [HTML (Derivative)](https://github.com/textmate/html.tmbundle/blob/m
5177` "patterns": [ { ... } ] `
5278An array of object pattern's to include.
5379If everything inside ` patterns ` fails with an error, then any [ begin] ( #begin ) rules will fail also.
54- If multiple conflicting rules appear , VSCode will pick the highest one from the list:
80+ If there are multiple conflicting rules, VSCode will pick the highest one from the list:
5581* [ include] ( #include )
5682* [ match] ( #match )
5783* [ begin] ( #begin ) /[ while] ( #while )
@@ -65,9 +91,9 @@ If multiple conflicting rules appear, VSCode will pick the highest one from the
6591` "repository": { "...": { ... } } `
6692A list of rules that can be later referenced with [ include] ( #include ) .
6793[ contributing-a-basic-grammar] ( https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#contributing-a-basic-grammar ) .
68- https://github.com/microsoft/vscode-textmate/issues/140
94+ VSCode [ Bug ] ( https://github.com/microsoft/vscode-textmate/issues/140 ) : If there is a [ match ] ( #match ) or [ begin ] ( #begin ) , then the ` repository ` is ignored.
6995Although you can name repo-rules anything you like, you cannot reference a rule named ` $self ` or ` $base `
70- If multiple conflicting rules appear , VSCode will pick the highest one from the list:
96+ If there are multiple conflicting rules, VSCode will pick the highest one from the list:
7197* [ match] ( #match )
7298* [ begin] ( #begin ) /[ while] ( #while )
7399* [ begin] ( #begin ) /[ end] ( #end )
@@ -93,13 +119,13 @@ Default priority is `0`, left `L:` is `-1` (higher) and Right `R:` is `1` (Lower
93119## fileTypes
94120` "fileTypes": [ "..." ] `
95121An array of file extensions your language supports.
96- VSCode acknowledges ` fileTypes ` , but doesn't do anything with it.
122+ VSCode TextMate acknowledges ` fileTypes ` , but doesn't do anything with it.
97123Use ` "extensions" ` under ` "languages" ` in your ` package.json ` file instead.
98124
99125## firstLineMatch
100126` "firstLineMatch": "..." `
101127A regex to detect if an open file should get assigned to your language.
102- VSCode acknowledges ` firstLineMatch ` , but doesn't do anything with it.
128+ VSCode TextMate acknowledges ` firstLineMatch ` , but doesn't do anything with it.
103129Use ` "firstLine" ` under ` "languages" ` in your ` package.json ` file instead.
104130
105131
@@ -118,6 +144,13 @@ However it cannot reference a [repository](#repository) at the same level as it,
118144` "name": "..." `
119145A list of space-separated scope-names to be assigned to the provided token.
120146VSCode will then colour that token using the scope names in the current theme.
147+
148+ TextMate 2.0 and Github do not separate scopes on spaces.
149+ But instead attempt to match the entire text (including spaces) against the theme-scopes.
150+ However they do separate theme scopes on spaces.
151+ So ` string.regexp meta.group ` will only match on ` string ` .
152+ Since ` regexp meta ` is not a valid scope-part.
153+
121154[ naming_conventions] ( https://macromates.com/manual/en/language_grammars#naming_conventions ) , [ themes] ( https://code.visualstudio.com/docs/getstarted/themes ) , [ theming] ( https://code.visualstudio.com/api/extension-capabilities/theming )
122155You should add your ` languageId ` as a suffix to all scope-names. example ` keyword.control.goto.cpp `
123156` comment ` , ` string ` and ` regex ` disables bracket matching while ` meta.embedded ` reenables it.
@@ -134,6 +167,7 @@ Also applies to the captured text when paired with [patterns](#patterns) inside
134167
135168## match
136169` "match": "..." `
170+ TextMate 2.0: If [ end] ( #end ) or [ while] ( #while ) does not exist, ` begin ` will be treated as [ match] ( #match ) .
137171[ Regex] ( README.md#regex ) used to tokenize and capture parts of a file.
138172[ name] ( #name ) is used to apply a scope-name to the whole text being matched.
139173[ captures] ( #captures ) is used to apply scope-names to specific capture groups and/or retokenize the capture groups.
@@ -144,6 +178,7 @@ All other rules are effectively ignored. Including [repository](#repository).
144178` "begin": "..." `
145179` begin ` starts a region that can span multiple lines.
146180An invisible 0-width anchor is placed directly after ` begin ` . The anchor can then be matched against using ` \\G ` .
181+ TextMate 2.0: If [ end] ( #end ) or [ while] ( #while ) exists, ` match ` will overwrite and be treated as [ begin] ( #begin ) .
147182[ Regex] ( README.md#regex ) just like [ match] ( #match ) .
148183[ name] ( #name ) is used to apply a scope-name to both the ` begin ` text and the entire region covered by ` begin ` /([ end] ( #end ) |[ while] ( #while ) ).
149184[ contentName] ( #contentname ) is used to apply a scope-name to the ** inner** region being covered (includes [ while] ( #while ) ).
@@ -174,20 +209,22 @@ If `end` is invalid it will either end immediately or carry on to the end of the
174209## while
175210` "while": "..." `
176211[ jeff-hykin textmate_while] ( https://github.com/jeff-hykin/better-cpp-syntax/blob/master/documentation/library/textmate_while.md )
177- ` while ` is checked once per line (starting on the line after the [ begin] ( #begin ) ) capturing the matched text.
212+ ` while ` is checked once per line (starting on the line after the [ begin] ( #begin ) ) capturing the matched text.
178213Items in the [ patterns] ( #patterns ) array are then checked after the captured ` while ` text.
179214` while ` places an invisible 0-width anchor after it. It can then be matched using ` \\G ` .
180- ` while ` is a lot more concrete than [ end] ( #end ) . It cannot be pushed out by items in the [ patterns] ( #patterns ) array.
215+ VSCode TextMate Bug: ` while ` is a lot more concrete than [ end] ( #end ) . It cannot be pushed out by items in the [ patterns] ( #patterns ) array.
216+ TextMate 2.0 & Github: ` while ` is not concrete, and can be pushed out by items in the [ patterns] ( #patterns ) array just like [ end] ( #end ) .
181217[ Regex] ( README.md#regex ) just like [ match] ( #match ) .
182218[ name] ( #name ) is used to apply a scope-name to the entire line matched by ` while ` .
183219[ contentName] ( #contentname ) is used to apply a scope-name to the entire line matched by ` while ` .
184220[ captures] ( #captures ) is used to apply scope-names to specific capture groups and/or retokenize the capture groups.
185221[ whileCaptures] ( #begincaptures ) is just like [ captures] ( #captures ) , but specifically targets ` while ` . It is prioritized over [ captures] ( #captures ) .
186222
187223## applyEndPatternLast
188- ` "applyEndPatternLast": true `
224+ ` "applyEndPatternLast": 1 `
189225Controls if the [ end] ( #end ) rule should attempt to match before or after the [ patterns] ( #patterns ) array.
190- ` 0 ` , ` false ` and ` null ` will disable it. ` true ` and numbers != ` 0 ` will enable it.
226+ VSCode TextMate: ` true ` and numbers != ` 0 ` will enable it. ` 0 ` , ` false ` and ` null ` will disable it.
227+ TextMate 2.0: ` true ` (` :true ` ) and ` 1 ` will enable it. ` false ` (` :false ` ) and numbers != ` 1 ` will disable it.
191228[ applyEndPatternLast check] ( https://github.com/microsoft/vscode-textmate/blob/main/src/rule.ts#L227 )
192229
193230## captures
@@ -284,8 +321,8 @@ In the format `[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA
284321Not supported by TextMate.
285322
286323## disabled
287- ` "disabled:" true `
288- Disables the current rule for easy testing.
324+ ` "disabled:" 1 `
325+ TextMate 2.0: Disables the current rule for easy testing.
289326Not currently supported by VSCode.
290327
291328## information_for_contributors
0 commit comments