Skip to content

Commit 2e7cc03

Browse files
fbriconrgrunber
authored andcommitted
Inject json syntax highlighting via language=json comment
Signed-off-by: Fred Bricon <[email protected]>
1 parent 295947f commit 2e7cc03

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"injectionSelector": "L:source.java -comment -string",
3+
"patterns": [
4+
{
5+
"contentName": "meta.embedded.block.json",
6+
"begin": "(?i)((/\\*\\s*(language=json)\\s*\\*/)|((//\\s*(language=json)\\s*)))",
7+
"beginCaptures": {
8+
"1": {
9+
"name": "comment.block"
10+
}
11+
},
12+
"end": "(?<=\")",
13+
"patterns": [
14+
{
15+
"begin": "\\s*(\"\"\")$",
16+
"beginCaptures": {
17+
"0": { "name": "string.quoted.triple.java" }
18+
},
19+
"end": "\\s*(\"\"\")",
20+
"endCaptures": {
21+
"0": { "name": "string.quoted.triple.java" }
22+
},
23+
"patterns": [
24+
{ "include": "source.json" }
25+
]
26+
},
27+
{
28+
"begin": "\\s*(\")",
29+
"beginCaptures": {
30+
"0": { "name": "string.quoted.double.java" }
31+
},
32+
"end": "\\s*(\")",
33+
"endCaptures": {
34+
"0": { "name": "string.quoted.double.java" }
35+
},
36+
"patterns": [
37+
{ "include": "source.json" }
38+
]
39+
}
40+
]
41+
}
42+
],
43+
"scopeName": "inline.json"
44+
}

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@
222222
"embeddedLanguages": {
223223
"meta.embedded.block.sql": "sql"
224224
}
225+
},
226+
{
227+
"injectTo": [
228+
"source.java"
229+
],
230+
"scopeName": "inline.json",
231+
"path": "./language-support/json/inline-json.json",
232+
"embeddedLanguages": {
233+
"meta.embedded.block.json": "json"
234+
}
225235
}
226236
],
227237
"jsonValidation": [

0 commit comments

Comments
 (0)