mirror of
https://github.com/James-Yu/LaTeX-Workshop.git
synced 2024-12-05 00:52:43 +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')
|
||||
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()
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -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",
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
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",
|
||||
"test/**/*.ts",
|
||||
"dev/**/*.ts",
|
||||
"dev/generate-bailout.js",
|
||||
"dev/latex-md.js"
|
||||
"dev/*.mjs"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
|
Loading…
Reference in New Issue
Block a user