Skip to content

Commit 808b848

Browse files
committed
Update script to retrieve grammar definitions
1 parent 439317e commit 808b848

7 files changed

+52
-23
lines changed
Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
const fs = require('fs')
2-
const path = require('path')
3-
const vel = require('vscode-extend-language')
1+
import fs from 'fs'
2+
import path from 'path'
3+
import {download, getCommitSha, expandConfigurationFile} from'vscode-extend-language'
44

5-
const syntaxDir = path.join(__dirname, '..', 'syntax')
5+
const syntaxDir = './syntax'
66

7+
/**
8+
* Download a file from a specific branch on a repo
9+
* @param {string} repo
10+
* @param {string} file
11+
* @param {string} version git branch to pull
12+
*/
713
async function downloadFile(repo, file, version='main') {
814
const url = 'https://raw.githubusercontent.com/' + repo + '/' + version + '/' + file
9-
var content = await vel.download(url)
15+
var content = await download(url)
1016
if (!content) {
1117
console.log('Cannot retrieve ', url)
1218
return
@@ -16,37 +22,50 @@ async function downloadFile(repo, file, version='main') {
1622
console.log('Updating', syntaxFilePath)
1723
}
1824

19-
async function main() {
25+
async function updateGrammars() {
2026
const latexBasicsRepo = 'jlelong/vscode-latex-basics'
2127
const grammarFiles = [
28+
'BibTeX-style.tmLanguage.json',
2229
'Bibtex.tmLanguage.json',
30+
'DocTeX.tmLanguage.json',
31+
'JLweave.tmLanguage.json',
2332
'LaTeX.tmLanguage.json',
33+
'Pweave.tmLanguage.json',
34+
'RSweave.tmLanguage.json',
2435
'TeX.tmLanguage.json',
2536
'cpp-grammar-bailout.tmLanguage.json',
2637
'markdown-latex-combined.tmLanguage.json'
2738
]
2839

29-
const sha = await vel.getCommitSha(latexBasicsRepo)
40+
const sha = await getCommitSha(latexBasicsRepo)
3041
if (sha) {
3142
console.log(`Update grammar files to ${latexBasicsRepo}@${sha}`)
3243
} else {
3344
console.log('Cannot read last commit information')
3445
}
3546
for (const file of grammarFiles) {
36-
downloadFile(latexBasicsRepo, 'syntaxes/' + file)
47+
void downloadFile(latexBasicsRepo, 'syntaxes/' + file)
3748
}
3849

50+
}
51+
52+
async function main() {
53+
54+
await updateGrammars()
3955
// The order of the files matters!
40-
languageFiles = [
56+
const languageFiles = [
57+
'latex-language-configuration.json',
4158
'latex-cpp-embedded-language-configuration.json',
4259
'markdown-latex-combined-language-configuration.json',
43-
'latex-language-configuration.json',
44-
'latex3-language-configuration.json'
60+
'latex3-language-configuration.json',
61+
'bibtex-language-configuration.json',
62+
'bibtex-style-language-configuration.json',
63+
'doctex-language-configuration.json'
4564
]
4665
for (const file of languageFiles) {
4766
console.log('Expanding', path.join(syntaxDir, file))
48-
await vel.expandConfigurationFile(path.join(syntaxDir, 'src', file), path.join(syntaxDir, file))
67+
await expandConfigurationFile(path.join(syntaxDir, 'src', file), path.join(syntaxDir, file))
4968
}
5069
}
5170

52-
main()
71+
await main()

package-lock.json

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2579,8 +2579,7 @@
25792579
"test": "node ./out/test/runTest.js",
25802580
"watch-src": "tsc -watch -p tsconfig.json",
25812581
"watch-viewer": "tsc -watch -p viewer/tsconfig.json",
2582-
"build-grammar": "node ./dev/build-grammar.js",
2583-
"update-grammar": "node ./dev/update-grammar.js"
2582+
"update-grammar": "node ./dev/update-grammar.mjs"
25842583
},
25852584
"dependencies": {
25862585
"cross-spawn": "7.0.3",
@@ -2619,6 +2618,6 @@
26192618
"rimraf": "5.0.5",
26202619
"textmate-bailout": "1.1.0",
26212620
"typescript": "5.3.3",
2622-
"vscode-extend-language": "0.1.2"
2621+
"vscode-extend-language": "^0.2.2"
26232622
}
26242623
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/bibtex-language-configuration.json"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/bibtex-style-language-configuration.json"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/doctex-language-configuration.json"
3+
}

tsconfig.eslint.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"src/**/*.ts",
55
"test/**/*.ts",
66
"dev/**/*.ts",
7-
"dev/generate-bailout.js",
8-
"dev/latex-md.js"
7+
"dev/*.mjs"
98
],
109
"compilerOptions": {
1110
"allowJs": true,

0 commit comments

Comments
 (0)