README
¶
SysML v2 for VS Code (OpenSysML)
Syntax highlighting and language support for .sysml and .kerml files, backed by
OpenSysML's sysml-lsp server: diagnostics, hover, go-to-definition, document
symbols, typed completion, a live diagram panel, and Markdown rendering of
native document definitions.
This extension is built and side-loaded from this repository. It is deliberately not published to the Visual Studio Marketplace or Open VSX.
Build and side-load
make build # from the repo root: builds bin/sysml-lsp
cd editors/vscode
npm install
npm run package # typecheck + bundle + opensysml-sysml.vsix
code --install-extension opensysml-sysml.vsix
Then open any .sysml file. The extension finds the server in this order:
opensysml.server.path, if set;bin/sysml-lspinside an open workspace folder (a repo checkout that ranmake build);sysml-lsponPATH.
If none exist, highlighting still works and a warning explains how to build the
server. SysML: Restart Language Server restarts it after a rebuild.
The diagram panel
SysML: Open Diagram opens a diagram of the active model beside it, drawn as
Mermaid from the server's rendering and redrawn as the model is typed.
| What it draws | The view the document declares, chosen in the picker when it declares several. A document declaring none is drawn directly, as a model tree, interconnection diagram, state diagram, action flow, sequence diagram or element table — a table is written as Markdown rather than drawn, and is shown as that. A view whose rendering is not supported (geometry, textual) is listed but not drawable, and the reason is written under the diagram. |
| Navigation | Click a node to open the declaration it was built from; moving the cursor in the editor highlights the node whose declaration contains it. A node with no locatable declaration, such as a standard library symbol, is inert. |
| While typing | A rendering that fails mid-keystroke leaves the last good diagram on screen, dimmed, with the error in the status line: the panel never blanks. What a rendering could not represent is listed under it. |
| Cost | The panel asks for a diagram only while visible, and only once an editing burst settles. Mermaid is bundled into the extension, and the panel's CSP allows the bundled script alone — nothing is fetched from the network. |
It is read-only — Tier 1 of the visual-modeling design: the diagram renders the model, and cannot edit it, has no persisted layout, and offers no authoring.
The command exists only when the server advertises
experimental: { openSysmlRender: true }, so an older sysml-lsp keeps working
without it. The requests behind the panel — opensysml/render,
opensysml/views and the opensysml/renderChanged notification — are documented
in docs/reference/lsp.md.
Rendering documents
SysML: Render Document renders a native document definition — a part def
specializing DocumentQueries::Document — to Markdown: a quick pick lists the
documents the workspace declares, and the rendering opens beside the editor as
a Markdown preview. It is the pipeline behind the REPL's %render-document,
run against the model as currently typed. An error — a query that fails to
plan, a binding that resolves to nothing — is shown as a message rather than a
crash.
The command exists only when the server advertises
experimental: { openSysmlRenderDocument: true }. The requests behind it —
opensysml/documents and opensysml/renderDocument — are documented in
docs/reference/lsp.md.
Settings
| Setting | Default | Meaning |
|---|---|---|
opensysml.server.path |
"" |
Absolute path to sysml-lsp; empty falls back to the workspace build, then PATH. |
opensysml.server.args |
[] |
Extra server arguments. |
opensysml.server.enabled |
true |
Set to false for highlighting without a server. |
opensysml.trace.server |
"off" |
Trace LSP traffic in the "SysML v2" output channel. |
Grammar generation
syntaxes/*.tmLanguage.json are generated — do not edit them by hand. The
keyword list comes from internal/core/lexer.Keywords(), and the contextual
words the parser reads as syntax without the lexer reserving them (point,
initial, var in .kerml, …) from lexer.ContextualWords(), so highlighting
cannot drift from either. Generation fails if a word is in both lists, and the
two languages differ where the grammars do — var is KerML notation only:
make vscode-grammar # regenerate
go test ./editors/... # fails if the committed grammars are stale
Development
npm run watch # rebuild dist/extension.js and dist/webview.js on change
npm run typecheck # tsc --noEmit, extension and webview
npm run check-nodes # render Mermaid fixtures and verify source-node matching
esbuild.mjs builds two bundles: the extension for Node, and the diagram
webview for the browser with Mermaid bundled in. They typecheck against
different libraries — the webview needs the DOM, the extension must not see it —
so src/webview has its own tsconfig.json.
Press F5 in VS Code with editors/vscode open to launch an Extension
Development Host. examples/demo.sysml is a highlighting smoke-test file.
Directories
¶
| Path | Synopsis |
|---|---|
|
tools
|
|
|
gengrammar
command
Command gengrammar writes the VS Code extension's TextMate grammars from the lexer's keyword list, so highlighting cannot drift from the language.
|
Command gengrammar writes the VS Code extension's TextMate grammars from the lexer's keyword list, so highlighting cannot drift from the language. |