Skip to content

Commit 0ec355a

Browse files
committed
Improve injections documentation
1 parent 1cd54e7 commit 0ec355a

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

documentation/injections.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## TextMate Injections
22

33
There are two different injection types:
4-
`"injectionSelector"` which is used with `"injectTo"` in `package.json`.
5-
`"injections"` which is only used within a (non-injected) grammar.
4+
[`"injectionSelector"`](#injectionselector) which is used with `"injectTo"` in `package.json`.
5+
[`"injections"`](#injections) which is only used within a (non-embedded/injected) grammar.
66

77
```json textmate
88
"injectionSelector": "L:text.html.markdown -meta.embedded.block.json.textmate"
@@ -29,20 +29,18 @@ A typical injection will look something like this:
2929
* `-string` not inject into `strings`
3030
* `,` separates multiple injection selectors
3131

32-
https://github.com/microsoft/vscode-textmate/blob/main/src/matcher.ts
33-
The injection syntax is parsed into the following tokens
34-
35-
* `L:` - `left` side priority selector `-1` to following the scopeName
36-
* `R:` - `right` side priority selector `1` to following the scopeName
32+
The injection [parser](https://github.com/microsoft/vscode-textmate/blob/main/src/matcher.ts) parses the syntax into the following tokens:
33+
* `L:` - `left` side priority selector `-1` to the following scopeName
34+
* `R:` - `right` side priority selector `1` to the following scopeName
3735
* `B:` - Both `left` and `right` side priority selectors (Github and [TextMate](https://github.com/textmate/textmate/blob/master/Frameworks/scope/src/types.h#L74) only. VSCode doesn't support it)
38-
* __*__`:` - any char followed by `:` colon. Defaults to priority `0` to following the scopeName
36+
* __*__`:` - any char followed by `:` colon. Defaults to priority `0` to the following scopeName
3937
* `(` - Open bracket group
4038
* `)` - Close bracket group
41-
* `-` - Negate following scopeName or group (negates each scopeName individually if inside group)
39+
* `-` - Negates the following scopeName or group (negates each scopeName individually within the group )
4240
* `,` - Logical `OR`
43-
* `|` - Logical `OR` (only when inside group)
41+
* `|` - Logical `OR` (only when inside a group)
4442
* `/[\w.:][\w.:-]*/` - Regex for scopeNames (`identifier`)
45-
* __*__ - any other character left over (including whitespace ` ` and asterisk `*`) becomes whitespace
43+
* __*__ - any other character left over is treated as whitespace
4644
* `*` - Asterisk matches against any scope; TextMate 2.0 only. VSCode treats it as whitespace
4745

4846
Any rogue closing bracket `)` or `|` (when at root level) will cause all text afterwards to be ignored.
@@ -88,7 +86,7 @@ Including recursively into the injected grammar.
8886
`"injections"` injects rules into the grammar based on the scopeNames specified.
8987

9088
Sadly in VSCode injections do not work if the grammar is embedded inside another grammar.
91-
You will need put the injections inside the parent grammar.
89+
You will need to put the injections inside the parent grammar.
9290

9391
TextMate will inject the rules into the entire document.
9492
Including recursively into the injected rules.

0 commit comments

Comments
 (0)