Siemens Language Support
This VS Code extension provides basic syntax highlighting for the Siemens custom language.
Bugs/incorrect/missing diagnostics can be reported to danielv@danielv.no - reproducible examples are appreciated.
Features
- Syntax highlighting via TextMate grammar
- Show variable datatypes on hover
- Comment toggling and bracket pairing via language configuration
- Check missing semicolons on statements and after END_* blocks
- Check unclosed blocks and missing required keywords (THEN/DO/OF/UNTIL, END_*)
- Check assignment to undefined locals (including nested struct/array member access)
- Check assignment to local constants declared in VAR CONSTANT
- Validate time literals T#/TIME#/LT#/LTIME# (format, segments, units)
- Validate bitstring and base‑prefixed literals (BYTE/WORD/DWORD/LWORD and 2#/8#/16#): base/digits present and value fits bit‑width
- Report unterminated strings, quoted identifiers, quoted local identifiers, and block comments
- Report unterminated attribute blocks { ... }
- Report unexpected characters and invalid standalone '#'
- Disallow static VAR blocks inside FUNCTION (only VAR CONSTANT is allowed)
- Validate block headers and metadata (e.g., VERSION, TITLE) and require values
- Handle REGION/END_REGION lines: rest of the REGION line is a comment; semicolons not required
- Validate .s7res resource files (YAML): structure, required id, scalar translation values
- Lightweight telemetry (session counts, open
.scl files) with opt-out via settings
File associations
Files ending in .scl, .s7res, .s7dcl, .udt, and .db will be highlighted.
PLC scopes with .plc.json
- Place a
.plc.json file in each PLC project folder to give it an isolated type scope. This keeps types from one PLC from spilling into another when you have multiple PLCs inside one VS Code workspace.
- The language server treats the folder containing
.plc.json (plus any extra libraries you list) as one scope. Every subdirectory under that PLC root automatically shares the same type index.
- Example configuration:
{
"name": "PackingLine PLC",
"description": "Main line controller",
"libraries": [
"../shared_types",
"../lib/opc_blocks"
]
}
libraries paths are resolved relative to the .plc.json file and must exist to be used.
- Type lookups never fall back to other PLC roots; each
.plc.json keeps its scope isolated.
- Editing or adding
.plc.json files causes the language server to rescan automatically.
Development
- Open this folder in VS Code and press F5 to launch the Extension Development Host.
Releases
npm version minor
npx vsce package
npx vsce publish
The extension should be published to:
Publishing to open-vsx is done manually from the website, vs marketplace is done with vsce publish with a PAT from https://dev.azure.com/nyedynamic