Skip to content

Commit

Permalink
Inject json syntax highlighting via language=json comment
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon authored and rgrunber committed Jan 10, 2024
1 parent 295947f commit 2e7cc03
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
44 changes: 44 additions & 0 deletions language-support/json/inline-json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"injectionSelector": "L:source.java -comment -string",
"patterns": [
{
"contentName": "meta.embedded.block.json",
"begin": "(?i)((/\\*\\s*(language=json)\\s*\\*/)|((//\\s*(language=json)\\s*)))",
"beginCaptures": {
"1": {
"name": "comment.block"
}
},
"end": "(?<=\")",
"patterns": [
{
"begin": "\\s*(\"\"\")$",
"beginCaptures": {
"0": { "name": "string.quoted.triple.java" }
},
"end": "\\s*(\"\"\")",
"endCaptures": {
"0": { "name": "string.quoted.triple.java" }
},
"patterns": [
{ "include": "source.json" }
]
},
{
"begin": "\\s*(\")",
"beginCaptures": {
"0": { "name": "string.quoted.double.java" }
},
"end": "\\s*(\")",
"endCaptures": {
"0": { "name": "string.quoted.double.java" }
},
"patterns": [
{ "include": "source.json" }
]
}
]
}
],
"scopeName": "inline.json"
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@
"embeddedLanguages": {
"meta.embedded.block.sql": "sql"
}
},
{
"injectTo": [
"source.java"
],
"scopeName": "inline.json",
"path": "./language-support/json/inline-json.json",
"embeddedLanguages": {
"meta.embedded.block.json": "json"
}
}
],
"jsonValidation": [
Expand Down

0 comments on commit 2e7cc03

Please sign in to comment.