Skip to content

Commit aff32bd

Browse files
committed
emit schema when doing JSON output
1 parent 0857894 commit aff32bd

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

build.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@ const plist = require("plist");
1414
const srcFile = path.join(__dirname, "src", "qsharp.tmLanguage.yml");
1515
const grammarsDir = path.join(__dirname, "grammars");
1616

17+
// JSON Schema for TextMate grammars. Emitted only into the JSON outputs (as the
18+
// first key)
19+
const JSON_SCHEMA = "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json";
20+
1721
function build() {
1822
const text = fs.readFileSync(srcFile, "utf8");
1923
const grammar = jsYaml.load(text);
2024

25+
const jsonGrammar = { $schema: JSON_SCHEMA, ...grammar };
26+
const jsonText = JSON.stringify(jsonGrammar, null, "\t") + "\n";
27+
2128
fs.mkdirSync(grammarsDir, { recursive: true });
2229

2330
fs.writeFileSync(
2431
path.join(grammarsDir, "qsharp.tmLanguage.json"),
25-
JSON.stringify(grammar, null, "\t") + "\n"
32+
jsonText
2633
);
2734

2835
fs.writeFileSync(
@@ -38,7 +45,7 @@ function build() {
3845
if (fs.existsSync(testExtDir)) {
3946
fs.writeFileSync(
4047
path.join(testExtDir, "qsharp.tmLanguage.json"),
41-
JSON.stringify(grammar, null, "\t") + "\n"
48+
jsonText
4249
);
4350
console.log("Refreshed test-extension/qsharp.tmLanguage.json");
4451
}

grammars/qsharp.tmLanguage.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
23
"name": "qsharp",
34
"scopeName": "source.qsharp",
45
"fileTypes": [

0 commit comments

Comments
 (0)