Skip to content

Commit

Permalink
Add SQL block highlighting support
Browse files Browse the repository at this point in the history
See microsoft/vscode-textmate#41 (comment)
for multi line matching
  • Loading branch information
lukas committed Dec 11, 2023
1 parent 7ef38c6 commit fb53eca
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
47 changes: 47 additions & 0 deletions language-support/sql/inline-sql.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"fileTypes": ["java"],
"injectionSelector": "L:source.java -comment -string ",
"patterns": [
{
"contentName": "meta.embedded.block.sql",
"begin": "(?i)((/\\*\\s*(language=sql)\\s*\\*/)|((//\\s*(language=sql)\\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.sql" },
{ "include": "source.plpgsql.postgres" }
]
},
{
"begin": "\\s*(\")",
"beginCaptures": {
"0": { "name": "string.quoted.double.java" }
},
"end": "\\s*(\")",
"endCaptures": {
"0": { "name": "string.quoted.double.java" }
},
"patterns": [
{ "include": "source.sql" },
{ "include": "source.plpgsql.postgres" }
]
}
]
}
],
"scopeName": "inline.sql"
}
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@
"language": "gradle-kotlin-dsl",
"scopeName": "source.kotlin",
"path": "./language-support/kotlin/kotlin.tmLanguage.json"
},
{
"injectTo": [
"source.java"
],
"scopeName": "inline.sql",
"path": "./language-support/sql/inline-sql.json",
"embeddedLanguages": {
"meta.embedded.block.sql": "sql"
}
}
],
"jsonValidation": [
Expand Down

0 comments on commit fb53eca

Please sign in to comment.