mirror of
https://github.com/James-Yu/LaTeX-Workshop.git
synced 2024-10-03 22:57:56 +03:00
Update script to retrieve grammar definitions
This commit is contained in:
parent
439317e235
commit
808b8480ef
@ -1,12 +1,18 @@
|
|||||||
const fs = require('fs')
|
import fs from 'fs'
|
||||||
const path = require('path')
|
import path from 'path'
|
||||||
const vel = require('vscode-extend-language')
|
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') {
|
async function downloadFile(repo, file, version='main') {
|
||||||
const url = 'https://raw.githubusercontent.com/' + repo + '/' + version + '/' + file
|
const url = 'https://raw.githubusercontent.com/' + repo + '/' + version + '/' + file
|
||||||
var content = await vel.download(url)
|
var content = await download(url)
|
||||||
if (!content) {
|
if (!content) {
|
||||||
console.log('Cannot retrieve ', url)
|
console.log('Cannot retrieve ', url)
|
||||||
return
|
return
|
||||||
@ -16,37 +22,50 @@ async function downloadFile(repo, file, version='main') {
|
|||||||
console.log('Updating', syntaxFilePath)
|
console.log('Updating', syntaxFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function updateGrammars() {
|
||||||
const latexBasicsRepo = 'jlelong/vscode-latex-basics'
|
const latexBasicsRepo = 'jlelong/vscode-latex-basics'
|
||||||
const grammarFiles = [
|
const grammarFiles = [
|
||||||
|
'BibTeX-style.tmLanguage.json',
|
||||||
'Bibtex.tmLanguage.json',
|
'Bibtex.tmLanguage.json',
|
||||||
|
'DocTeX.tmLanguage.json',
|
||||||
|
'JLweave.tmLanguage.json',
|
||||||
'LaTeX.tmLanguage.json',
|
'LaTeX.tmLanguage.json',
|
||||||
|
'Pweave.tmLanguage.json',
|
||||||
|
'RSweave.tmLanguage.json',
|
||||||
'TeX.tmLanguage.json',
|
'TeX.tmLanguage.json',
|
||||||
'cpp-grammar-bailout.tmLanguage.json',
|
'cpp-grammar-bailout.tmLanguage.json',
|
||||||
'markdown-latex-combined.tmLanguage.json'
|
'markdown-latex-combined.tmLanguage.json'
|
||||||
]
|
]
|
||||||
|
|
||||||
const sha = await vel.getCommitSha(latexBasicsRepo)
|
const sha = await getCommitSha(latexBasicsRepo)
|
||||||
if (sha) {
|
if (sha) {
|
||||||
console.log(`Update grammar files to ${latexBasicsRepo}@${sha}`)
|
console.log(`Update grammar files to ${latexBasicsRepo}@${sha}`)
|
||||||
} else {
|
} else {
|
||||||
console.log('Cannot read last commit information')
|
console.log('Cannot read last commit information')
|
||||||
}
|
}
|
||||||
for (const file of grammarFiles) {
|
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!
|
// The order of the files matters!
|
||||||
languageFiles = [
|
const languageFiles = [
|
||||||
|
'latex-language-configuration.json',
|
||||||
'latex-cpp-embedded-language-configuration.json',
|
'latex-cpp-embedded-language-configuration.json',
|
||||||
'markdown-latex-combined-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) {
|
for (const file of languageFiles) {
|
||||||
console.log('Expanding', path.join(syntaxDir, file))
|
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()
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -45,7 +45,7 @@
|
|||||||
"rimraf": "5.0.5",
|
"rimraf": "5.0.5",
|
||||||
"textmate-bailout": "1.1.0",
|
"textmate-bailout": "1.1.0",
|
||||||
"typescript": "5.3.3",
|
"typescript": "5.3.3",
|
||||||
"vscode-extend-language": "0.1.2"
|
"vscode-extend-language": "^0.2.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.74.0"
|
"vscode": "^1.74.0"
|
||||||
@ -5748,10 +5748,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vscode-extend-language": {
|
"node_modules/vscode-extend-language": {
|
||||||
"version": "0.1.2",
|
"version": "0.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/vscode-extend-language/-/vscode-extend-language-0.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/vscode-extend-language/-/vscode-extend-language-0.2.2.tgz",
|
||||||
"integrity": "sha512-Dy0mm9+Ox8ZlG1gpgLphRulwR3skL+qJoEF4dzQd4G+bfLKF+jkf8FVRo6FIItrWf6oyeZIZG6jE9mwY68su8g==",
|
"integrity": "sha512-434sPq/bwXPrVeS7CJAuFUg9vEfW1WnjZUhADQ9baVUnyeOaTNpOKNauXJzw4xSdqb3Tk9yz1Wg44PWFv4/haw==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=16"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/webidl-conversions": {
|
"node_modules/webidl-conversions": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
|
@ -2579,8 +2579,7 @@
|
|||||||
"test": "node ./out/test/runTest.js",
|
"test": "node ./out/test/runTest.js",
|
||||||
"watch-src": "tsc -watch -p tsconfig.json",
|
"watch-src": "tsc -watch -p tsconfig.json",
|
||||||
"watch-viewer": "tsc -watch -p viewer/tsconfig.json",
|
"watch-viewer": "tsc -watch -p viewer/tsconfig.json",
|
||||||
"build-grammar": "node ./dev/build-grammar.js",
|
"update-grammar": "node ./dev/update-grammar.mjs"
|
||||||
"update-grammar": "node ./dev/update-grammar.js"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-spawn": "7.0.3",
|
"cross-spawn": "7.0.3",
|
||||||
@ -2619,6 +2618,6 @@
|
|||||||
"rimraf": "5.0.5",
|
"rimraf": "5.0.5",
|
||||||
"textmate-bailout": "1.1.0",
|
"textmate-bailout": "1.1.0",
|
||||||
"typescript": "5.3.3",
|
"typescript": "5.3.3",
|
||||||
"vscode-extend-language": "0.1.2"
|
"vscode-extend-language": "^0.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
syntax/src/bibtex-language-configuration.json
Normal file
3
syntax/src/bibtex-language-configuration.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/bibtex-language-configuration.json"
|
||||||
|
}
|
3
syntax/src/bibtex-style-language-configuration.json
Normal file
3
syntax/src/bibtex-style-language-configuration.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/bibtex-style-language-configuration.json"
|
||||||
|
}
|
3
syntax/src/doctex-language-configuration.json
Normal file
3
syntax/src/doctex-language-configuration.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "https://raw.githubusercontent.com/jlelong/vscode-latex-basics/main/languages/doctex-language-configuration.json"
|
||||||
|
}
|
@ -4,8 +4,7 @@
|
|||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
"test/**/*.ts",
|
"test/**/*.ts",
|
||||||
"dev/**/*.ts",
|
"dev/**/*.ts",
|
||||||
"dev/generate-bailout.js",
|
"dev/*.mjs"
|
||||||
"dev/latex-md.js"
|
|
||||||
],
|
],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user