diff --git a/dev/update-grammar.js b/dev/update-grammar.mjs similarity index 54% rename from dev/update-grammar.js rename to dev/update-grammar.mjs index 98efd12bb..09b5c7be1 100644 --- a/dev/update-grammar.js +++ b/dev/update-grammar.mjs @@ -1,12 +1,18 @@ -const fs = require('fs') -const path = require('path') -const vel = require('vscode-extend-language') +import fs from 'fs' +import path from 'path' +import {download, getCommitSha, expandConfigurationFile} from'vscode-extend-language' -const syntaxDir = path.join(__dirname, '..', 'syntax') +const syntaxDir = './syntax' +/** + * Download a file from a specific branch on a repo + * @param {string} repo + * @param {string} file + * @param {string} version git branch to pull + */ async function downloadFile(repo, file, version='main') { const url = 'https://raw.githubusercontent.com/' + repo + '/' + version + '/' + file - var content = await vel.download(url) + var content = await download(url) if (!content) { console.log('Cannot retrieve ', url) return @@ -16,37 +22,50 @@ async function downloadFile(repo, file, version='main') { console.log('Updating', syntaxFilePath) } -async function main() { +async function updateGrammars() { const latexBasicsRepo = 'jlelong/vscode-latex-basics' const grammarFiles = [ + 'BibTeX-style.tmLanguage.json', 'Bibtex.tmLanguage.json', + 'DocTeX.tmLanguage.json', + 'JLweave.tmLanguage.json', 'LaTeX.tmLanguage.json', + 'Pweave.tmLanguage.json', + 'RSweave.tmLanguage.json', 'TeX.tmLanguage.json', 'cpp-grammar-bailout.tmLanguage.json', 'markdown-latex-combined.tmLanguage.json' ] - const sha = await vel.getCommitSha(latexBasicsRepo) + const sha = await getCommitSha(latexBasicsRepo) if (sha) { console.log(`Update grammar files to ${latexBasicsRepo}@${sha}`) } else { console.log('Cannot read last commit information') } for (const file of grammarFiles) { - downloadFile(latexBasicsRepo, 'syntaxes/' + file) + void downloadFile(latexBasicsRepo, 'syntaxes/' + file) } +} + +async function main() { + + await updateGrammars() // The order of the files matters! - languageFiles = [ + const languageFiles = [ + 'latex-language-configuration.json', 'latex-cpp-embedded-language-configuration.json', 'markdown-latex-combined-language-configuration.json', - 'latex-language-configuration.json', - 'latex3-language-configuration.json' + 'latex3-language-configuration.json', + 'bibtex-language-configuration.json', + 'bibtex-style-language-configuration.json', + 'doctex-language-configuration.json' ] for (const file of languageFiles) { console.log('Expanding', path.join(syntaxDir, file)) - await vel.expandConfigurationFile(path.join(syntaxDir, 'src', file), path.join(syntaxDir, file)) + await expandConfigurationFile(path.join(syntaxDir, 'src', file), path.join(syntaxDir, file)) } } -main() +await main() diff --git a/package-lock.json b/package-lock.json index 34d90daaa..196b35068 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "rimraf": "5.0.5", "textmate-bailout": "1.1.0", "typescript": "5.3.3", - "vscode-extend-language": "0.1.2" + "vscode-extend-language": "^0.2.2" }, "engines": { "vscode": "^1.74.0" @@ -5748,10 +5748,13 @@ } }, "node_modules/vscode-extend-language": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/vscode-extend-language/-/vscode-extend-language-0.1.2.tgz", - "integrity": "sha512-Dy0mm9+Ox8ZlG1gpgLphRulwR3skL+qJoEF4dzQd4G+bfLKF+jkf8FVRo6FIItrWf6oyeZIZG6jE9mwY68su8g==", - "dev": true + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/vscode-extend-language/-/vscode-extend-language-0.2.2.tgz", + "integrity": "sha512-434sPq/bwXPrVeS7CJAuFUg9vEfW1WnjZUhADQ9baVUnyeOaTNpOKNauXJzw4xSdqb3Tk9yz1Wg44PWFv4/haw==", + "dev": true, + "engines": { + "node": ">=16" + } }, "node_modules/webidl-conversions": { "version": "3.0.1", diff --git a/package.json b/package.json index bdb947ee9..475956738 100644 --- a/package.json +++ b/package.json @@ -2579,8 +2579,7 @@ "test": "node ./out/test/runTest.js", "watch-src": "tsc -watch -p tsconfig.json", "watch-viewer": "tsc -watch -p viewer/tsconfig.json", - "build-grammar": "node ./dev/build-grammar.js", - "update-grammar": "node ./dev/update-grammar.js" + "update-grammar": "node ./dev/update-grammar.mjs" }, "dependencies": { "cross-spawn": "7.0.3", @@ -2619,6 +2618,6 @@ "rimraf": "5.0.5", "textmate-bailout": "1.1.0", "typescript": "5.3.3", - "vscode-extend-language": "0.1.2" + "vscode-extend-language": "^0.2.2" } } diff --git a/syntax/src/bibtex-language-configuration.json b/syntax/src/bibtex-language-configuration.json new file mode 100644 index 000000000..9d05cae39 --- /dev/null +++ b/syntax/src/bibtex-language-configuration.json @@ -0,0 +1,3 @@ +{ + "extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/bibtex-language-configuration.json" +} diff --git a/syntax/src/bibtex-style-language-configuration.json b/syntax/src/bibtex-style-language-configuration.json new file mode 100644 index 000000000..c0a81ab01 --- /dev/null +++ b/syntax/src/bibtex-style-language-configuration.json @@ -0,0 +1,3 @@ +{ + "extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/bibtex-style-language-configuration.json" +} diff --git a/syntax/src/doctex-language-configuration.json b/syntax/src/doctex-language-configuration.json new file mode 100644 index 000000000..beea43f2a --- /dev/null +++ b/syntax/src/doctex-language-configuration.json @@ -0,0 +1,3 @@ +{ + "extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/doctex-language-configuration.json" +} diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index ffb4b388e..0fdbc64a3 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -4,8 +4,7 @@ "src/**/*.ts", "test/**/*.ts", "dev/**/*.ts", - "dev/generate-bailout.js", - "dev/latex-md.js" + "dev/*.mjs" ], "compilerOptions": { "allowJs": true,