VS Code Extension
The kuml-vscode extension brings kUML to Visual Studio Code and any VS Code-compatible
editor (Cursor, VSCodium, Code Server). The extension itself is a thin TypeScript client —
no Kotlin extension dependency for syntax highlighting and snippets — but diagnostics,
completion, and rendering are backed by two external processes it shells out to or
speaks LSP with: the kuml CLI and the kuml-lsp language server (see
CLI Reference and kuml-language-server). Both need to be installed
separately; see Requirements.
Install
Extensions sidebar → Search "kUML" → Install.
Or install a local .vsix distribution built from source (the extension lives in its
own repository, https://github.com/kuml-dev/kuml-vscode):
git clone git@github.com:kuml-dev/kuml-vscode.git
cd kuml-vscode
npm install
npm run package
# → kuml-vscode-0.X.Y.vsix
code --install-extension kuml-vscode-0.X.Y.vsix
Requirements
-
The
kumlCLI must be installed and reachable onPATH(or pointed at via thekuml.cliPathsetting). The render command and the live preview’s CLI fallback both shell out tokuml render. -
The
kuml-lsplanguage server binary must also be reachable — discovered the same way askuml: an explicit path (kuml.lspPathsetting orKUML_LSPenv var) →PATH→ Homebrew (/opt/homebrew/bin,/usr/local/bin) /~/.local/bin→ a local Gradle build. If you’re running from a clone of thekUMLrepo rather than an installed distribution, run./gradlew :kuml-language-server:installDistfirst sokuml-language-server/build/install/kuml-lsp/bin/kuml-lspexists for the walk-up discovery to find. -
Syntax highlighting and snippets work without either binary installed — only diagnostics, completion, rendering, and the live preview need them.
What you get
-
Syntax highlighting — own TextMate grammar (
source.kuml) with Kotlin basics plus a dedicated#kuml-dslpattern group. Diagram entry points, UML DSL builders, and C4 DSL builders all highlight as first-class language constructs. Works offline, no dependency on a third-party Kotlin extension. -
File icon — distinct icon for
*.kuml.ktsfiles in the Explorer and editor tabs (light and dark variants). -
Snippets — type any of these prefixes and
Tabto expand:Prefix Expands to diagramEmpty class diagram with a name placeholder.
umlModelumlModel { classDiagram { … } }wrapper.classOfClass with attribute, operation, and stereotype placeholders.
interfaceOfInterface with one operation.
enumOfEnum with two literal placeholders.
c4ModelPerson + SoftwareSystem + Container +
systemContextDiagram.associationBinary association with role names and multiplicities.
generalizationInheritance between a child and a parent.
realizationImplements between a class and an interface.
stateMachineState machine with initial, two states, two transitions.
applyProfileapplyProfile(…)with the five built-in profiles as a choice list. -
Render command — kUML: Render to SVG (command palette, editor title bar, or editor context menu). Shells out to
kuml render, writes to a temp file, opens the result. Works on unsaved buffers too. SVG output routes into the live-preview panel (see below); PNG output still opens in the OS’s default image viewer. -
Diagnostics + completion via the
kuml-lsplanguage server — parse and validation errors are pushed as you type (debounced), and completion (including resolve) is available for DSL builders and identifiers, over stdio viavscode-languageclient. -
kUML: Open Live Preview — a persistent webview panel that renders the active document as sanitized inline SVG and re-renders automatically on save and when you switch to another
*.kuml.ktseditor tab. -
kUML: Restart Language Server — stops and relaunches
kuml-lspwithout reloading the whole extension host window.
Configuration
Seven settings, all under kuml.*:
| Setting | Default | Description |
|---|---|---|
|
|
Path to the |
|
|
Default |
|
|
Output format for kUML: Render to SVG ( |
|
|
Explicit path to the |
|
|
Base URL of a running |
|
|
Enable push diagnostics from the language server. |
|
|
Debounce interval (ms) between an edit and the server re-validating the document. |
Edit via Settings → Extensions → kUML, or directly in settings.json:
{
"kuml.cliPath": "/usr/local/bin/kuml",
"kuml.theme": "elegant",
"kuml.format": "svg",
"kuml.serverUrl": "http://127.0.0.1:8080"
}
Render command — how it works
When you trigger kUML: Render to SVG on the active buffer:
-
The extension writes the buffer’s text to a temp file in
os.tmpdir(). This works for unsaved buffers and for Untitled documents. -
It spawns
kuml render --theme … --format … --output <tmpOut> <tmpSrc>(no shell, so paths with spaces and special characters are safe). -
On success: SVG output opens in the live-preview panel; PNG opens in the OS viewer because VS Code’s binary handling is awkward.
-
On failure: notification with the trimmed CLI stderr; if
ENOENT, hints at thekuml.cliPathsetting.
Live preview — dual render strategy
The kUML: Open Live Preview panel renders via two strategies, in order:
-
kuml serveHTTP API — ifkuml.serverUrlis set (e.g.http://127.0.0.1:8080, from a locally runningkuml serve --port …), the panel POSTs to{serverUrl}/api/renderand inlines the returned SVG. -
CLI fallback — if
kuml.serverUrlis empty, or the HTTP call fails for any reason, the panel shells out tokuml renderagainst a temp-file snapshot of the buffer (works for unsaved/dirty documents too).
Only SVG is inlined into the webview. The panel re-renders on save and whenever you
switch to another *.kuml.kts editor tab.
What’s deliberately NOT in scope
This extension is intentionally minimal — it gives you a good editor without trying to be a full IDE. The following are deliberately left out for now:
-
Hover, go-to-definition, rename, and code actions.
-
Any custom render request on the LSP itself — the server stays render-agnostic; all rendering is a client-side concern.
For OCL validation and code generation, use the dev.kuml Gradle plugin or the CLI
directly.
Troubleshooting
| Symptom | Likely cause |
|---|---|
kUML: Render to SVG prompts "kUML CLI is not on PATH" |
|
Render fails with a script syntax error |
The buffer has a syntax problem. Save the buffer and run |
File opens as plain text |
The file extension isn’t |
Snippets don’t show up |
Snippets are scoped to the |
No diagnostics or completion appear |
|
Live preview stays blank or shows a stale diagram |
If |