Skip to content

Commit

Permalink
Inject yaml syntax highlighting via language=yaml 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 8c74710 commit ce49c30
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
44 changes: 44 additions & 0 deletions language-support/yaml/inline-yaml.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.yaml",
"begin": "(?i)((/\\*\\s*(language=yaml)\\s*\\*/)|((//\\s*(language=yaml)\\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.yaml" }
]
},
{
"begin": "\\s*(\")",
"beginCaptures": {
"0": { "name": "string.quoted.double.java" }
},
"end": "\\s*(\")",
"endCaptures": {
"0": { "name": "string.quoted.double.java" }
},
"patterns": [
{ "include": "source.yaml" }
]
}
]
}
],
"scopeName": "inline.yaml"
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@
"embeddedLanguages": {
"meta.embedded.block.xml": "xml"
}
},
{
"injectTo": [
"source.java"
],
"scopeName": "inline.yaml",
"path": "./language-support/yaml/inline-yaml.json",
"embeddedLanguages": {
"meta.embedded.block.yaml": "yaml"
}
}
],
"jsonValidation": [
Expand Down

0 comments on commit ce49c30

Please sign in to comment.