vscode-extend-language
v0.3.0
Published
Utility to generate a new language configuration file for VS Code by extending an existing one.
Maintainers
Readme
Utility to extend languages in VS Code
Currently, it is not possible to build a new language as an extension of an existing one, the language-configuration.json file must be self-contained. This can lead to tedious maintenance as changes to the base language have to be forwarded manually. This package aims at helping language developers.
Assume you wand to derive a new language configuration from A-language-configuration.json, you just need to define a file let us say B.extension.language-configuration.json containing
{
"extends": "path/to/A-language-configuration.json",
"overrides": {
"comments": {
"blockComment": [
"<!--",
"-->"
]
},
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"],
["$", "$"],
["`", "`"],
["_", "_"],
["*", "*"]
],
},
"folding": {
"offSide": true,
"markers": {
"start": "^\\s*<!--\\s*#?region\\b.*-->",
"end": "^\\s*<!--\\s*#?endregion\\b.*-->"
}
}
}extendsmeans that languageBis based on the language configuration of languageA.path/to/A-language-configuration.jsoncan either be a relative local path toA-language-configuration.jsonor an url.- The
overridessection allows to replace some settings ofA-language-configuration.jsonby their new values inB. - Everything outside the
overridessection is added to theBconfiguration. If the key already exists inA-language-configuration.json, it must be an array and in this case their contents are concatenated.
To obtain the self-contained language configuration file for B, B.language-configuration.json, use
const vel = require('vscode-extend-language')
vel.expandConfigurationFile('./B.extension.language-configuration.json', './B.language-configuration.json')