Skip to content

Commit fd3915f

Browse files
committed
feat(syntaxes): add es6 template strings support
Fix #41
1 parent 77b0145 commit fd3915f

4 files changed

Lines changed: 78 additions & 1 deletion

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Supported languages are **Python**, **Go**, **JavaScript**, **TypeScript**, **Ru
1010
Syntax highlighting works for strings starting with `--sql` or any of
1111
the `SELECT`, `INSERT`, `INTO`, `DELETE`, `UPDATE`, `CREATE TABLE`.
1212

13+
Also works with ES6 Template Strings:
14+
15+
```javascript
16+
const query = sql`
17+
select * from book;
18+
`;
19+
```
20+
1321
**Linting and diagnostics powered entirely by awesome
1422
[joereynolds/sql-lint](https://github.com/joereynolds/sql-lint) and works for
1523
multiline strings that start with either <code>\`--sql</code> (backtick followed by `--sql`),

package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "inline-sql-syntax",
33
"displayName": "Inline SQL",
44
"description": "Highlight and lint SQL strings and SQL files. Python, Go, Rust, JS, TS, Ruby, Java, C#, PHP.",
5-
"version": "2.14.0",
5+
"version": "2.15.0",
66
"author": "qufiwefefwoyn <qufiwefefwoyn@gmail.com>",
77
"publisher": "qufiwefefwoyn",
88
"license": "MIT",
@@ -91,6 +91,21 @@
9191
"embeddedLanguages": {
9292
"meta.embedded.sql": "sql"
9393
}
94+
},
95+
{
96+
"path": "./syntaxes/es6_inline.json",
97+
"scopeName": "es6_inline",
98+
"injectTo": [
99+
"source.js",
100+
"source.js.jsx",
101+
"source.jsx",
102+
"source.ts",
103+
"source.tsx"
104+
],
105+
"embeddedLanguages": {
106+
"meta.embedded.sql": "sql",
107+
"meta.template.expression.ts": "typescript"
108+
}
94109
}
95110
],
96111
"configuration": {

syntaxes/es6_inline.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"scopeName": "es6_inline",
3+
"fileTypes": [
4+
"js",
5+
"jsx",
6+
"ts",
7+
"tsx"
8+
],
9+
"injectionSelector": "L:source.js -comment -string, L:source.jsx -comment -string, L:source.js.jsx -comment -string, L:source.ts -comment -string, L:source.js (string.quoted.double.html, string.quoted.single.html), L:source.jsx (string.quoted.double.html, string.quoted.single.html), L:source.js.jsx (string.quoted.double.html, string.quoted.single.html), L:source.ts (string.quoted.double.html, string.quoted.single.html), L:source.tsx (string.quoted.double.html, string.quoted.single.html)",
10+
"injections": {
11+
"L:source": {
12+
"patterns": [
13+
{
14+
"match": "<",
15+
"name": "invalid.illegal.bad-angle-bracket.html"
16+
}
17+
]
18+
}
19+
},
20+
"patterns": [
21+
{
22+
"contentName": "meta.embedded.sql",
23+
"begin": "(?x)(\\s*?(\\w+\\.)?(?:sql|/\\*\\s*sql\\s*\\*/)\\s*)(`)",
24+
"beginCaptures": {
25+
"0": {
26+
"name": "string.template.ts, punctuation.definition.string.template.begin.ts"
27+
},
28+
"1": {
29+
"name": "entity.name.function.tagged-template.ts"
30+
}
31+
},
32+
"end": "(`)",
33+
"endCaptures": {
34+
"0": {
35+
"name": "string.template.ts, punctuation.definition.string.template.end.ts"
36+
}
37+
},
38+
"patterns": [
39+
{
40+
"include": "source.ts#template-substitution-element"
41+
},
42+
{
43+
"include": "source.sql"
44+
}
45+
]
46+
},
47+
{
48+
"include": "source.ts#template-substitution-element"
49+
}
50+
]
51+
}

test/testdata/es6.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const query = sql`
2+
select * from book;
3+
`;

0 commit comments

Comments
 (0)