Thank you for your work. It really does work well, and it enables a much better experience working in VS Code.
I’ve implemented a simple extension myself, which only handles syntax highlighting and encoding configuration.
The encoding configuration feature would be great to add, and isn’t too complex. All is needed, is to declare two rapid languages in package.json.contributes.languages, that both use the same language-configuration.json file :
"contributes": {
"languages": [
{
"id": "rapid",
"aliases": [
"RAPID",
"rapid",
"rapid-omnicore"
],
"extensions": [
".modx",
".sysx"
],
"firstLine": "^\\s*MODULE\\b",
"configuration": "./language-configs/rapid-language-configuration.json"
},
{
"id": "rapid-irc5",
"aliases": [
"RAPID-IRC5",
"RAPID-IRC",
"rapid-irc5"
],
"extensions": [
".mod",
".sys"
],
"filenamePatterns": [
"*.mod"
],
"firstLine": "^\\s*MODULE\\b",
"configuration": "./language-configs/rapid-language-configuration.json"
},
{
"id": "eio-config",
"aliases": [
"EIO Configuration"
],
"extensions": [
".cfg"
],
"filenamePatterns": [
"EIO.cfg"
],
"configuration": "./language-configs/syspar-language-configuration.json"
},
{
"id": "mmc-config",
"aliases": [
"MMC Configuration"
],
"extensions": [
".cfg"
],
"filenamePatterns": [
"MMC.cfg"
],
"configuration": "./language-configs/syspar-language-configuration.json"
},
{
"id": "moc-config",
"aliases": [
"MOC Configuration"
],
"extensions": [
".cfg"
],
"filenamePatterns": [
"MOC.cfg"
],
"configuration": "./language-configs/syspar-language-configuration.json"
},
{
"id": "proc-config",
"aliases": [
"PROC Configuration"
],
"extensions": [
".cfg"
],
"filenamePatterns": [
"PROC.cfg"
],
"configuration": "./language-configs/syspar-language-configuration.json"
},
{
"id": "sio-config",
"aliases": [
"SIO Configuration"
],
"extensions": [
".cfg"
],
"filenamePatterns": [
"SIO.cfg"
],
"configuration": "./language-configs/syspar-language-configuration.json"
},
{
"id": "sys-config",
"aliases": [
"SYS Configuration"
],
"extensions": [
".cfg"
],
"filenamePatterns": [
"SYS.cfg"
],
"configuration": "./language-configs/syspar-language-configuration.json"
}
],
"grammars": [
{
"language": "rapid",
"scopeName": "source.rapid",
"path": "./syntaxes/rapid.tmLanguage.json"
},
{
"language": "rapid-irc5",
"scopeName": "source.rapid",
"path": "./syntaxes/rapid.tmLanguage.json"
},
{
"language": "eio-config",
"scopeName": "source.eio",
"path": "./syntaxes/eio.tmLanguage.json"
},
{
"language": "mmc-config",
"scopeName": "source.sys",
"path": "./syntaxes/sys.tmLanguage.json"
},
{
"language": "moc-config",
"scopeName": "source.sys",
"path": "./syntaxes/sys.tmLanguage.json"
},
{
"language": "proc-config",
"scopeName": "source.sys",
"path": "./syntaxes/sys.tmLanguage.json"
},
{
"language": "sio-config",
"scopeName": "source.sys",
"path": "./syntaxes/sys.tmLanguage.json"
},
{
"language": "sys-config",
"scopeName": "source.sys",
"path": "./syntaxes/sys.tmLanguage.json"
}
],
"configurationDefaults": {
"[rapid]": {
"files.encoding": "utf8"
},
"[rapid-irc5]": {
"files.encoding": "windows1252"
},
"[eio-config]": {
"files.encoding": "windows1252"
},
"[sys-config]": {
"files.encoding": "windows1252"
},
"[moc-config]": {
"files.encoding": "windows1252"
},
"[sio-config]": {
"files.encoding": "windows1252"
}
}
},
The configurationDefaults allows to configure the defaults encodings with the detected language.
I’ve declared two language configuration files (rapid-language-configuration.json and syspar-language-configuration.json). The only difference between the two is comments.lineComment, which is a ! for rapid, and a # for the syspar files.
Another feature is the coloring of the signal types in the EIO.cfg file. I’m not sure that it’s the correct way of doing it, but by declaring a separate ./syntaxes/eio.tmLanguage.json file, it allows the user to declare a custom theme which highlights the declared types :
./syntaxes/eio.tmLanguage.json :
{
"name": "EIO Config",
"scopeName": "source.cfg",
"patterns": [
{
"name": "comment.line.hash.cfg",
"match": "^#.*$"
},
{
"name": "keyword.header.cfg",
"match": "^\\s*(SYS|SIO|EIO|MOC|MMC|PROC)\\s*:.*::\\s*$"
},
{
"name": "constant.signal-type.di.eio",
"match": "(?<=-SignalType\\s)\"DI\""
},
{
"name": "constant.signal-type.do.eio",
"match": "(?<=-SignalType\\s)\"DO\""
},
{
"name": "constant.signal-type.gi.eio",
"match": "(?<=-SignalType\\s)\"GI\""
},
{
"name": "constant.signal-type.go.eio",
"match": "(?<=-SignalType\\s)\"GO\""
},
{
"name": "support.function.act-invert.eio",
"match": "Act\\d_invert"
},
{
"name": "constant.fs0e.eio",
"match": "(\"FSoE\")"
},
{
"name": "constant.language.record_parameters.cfg",
"match": "^\\s*[A-Z_]+\\s*:"
},
{
"name": "string.quoted.double.cfg",
"match": "\"([^\"\\\\]|\\\\.)*\""
},
{
"name": "constant.numeric.float.cfg",
"match": "\\b\\d+\\.\\d+\\b"
},
{
"name": "constant.numeric.integer.cfg",
"match": "\\b\\d+\\b"
},
{
"name": "variable.parameter.field.cfg",
"match": "(?:^|\\s)(\\-[a-zA-Z_][a-zA-Z0-9_]*)",
"captures": {
"1": { "name": "variable.parameter.field.cfg" }
}
}
]
}
I’ll be looking for the next update !