Skip to main content

VS Code Extension

The Verum Language Support extension is the primary IDE integration for Verum. It is a thin VS Code wrapper around verum lsp and verum dap — the heavy lifting (parsing, type-checking, refinement validation, CBGR analysis, SMT-backed verification) happens in the verum binary. The extension contributes the editor surface: highlighting, snippets, commands, inlay hints, code actions, the profile dashboard, and the debug integration.

Install​

From the Marketplace​

ext install verum-lang.verum

From a .vsix file​

code --install-extension ./verum-language.vsix

The extension requires the verum binary on $PATH (or set verum.lsp.serverPath to an absolute path). Install the toolchain per Installation.

What ships inside​

ComponentWhat it doesPowered by
TextMate grammarOffline syntax highlighting grammar-complete against the EBNF specification — keywords, refinement predicates, raw multiline strings, tagged literals, @attribute(args).syntaxes/verum.tmLanguage.json
Semantic highlightingLSP-driven additions on top of TextMate: refinement vs. regular types, CBGR reference tiers, proof identifiers, context providers / consumers.verum lsp → textDocument/semanticTokens
SnippetsPrefix-driven scaffolds for type is, is protocol { }, implement for, mount, fn-verify-formal, nursery, select, refinement shapes, tagged literals, proof blocks.snippets/verum.json
DiagnosticsVersioned compiler diagnostics for open buffers; explicit cursor-refinement results have separate proof status.verum lsp → textDocument/publishDiagnostics
Code actionsPromote &T → &checked T, insert runtime-check fallback, weaken refinement, convert to sigma type.textDocument/codeAction
Inlay hintsInferred refinement types, inferred generic parameters, CBGR tier hints.textDocument/inlayHint
Profile dashboardWebview showing verification / CBGR / compile metrics, hot-spot navigation.verum/getProfile custom request
Debug adapterLaunch / step / breakpoints via verum dap speaking DAP over stdio.verum dap --transport stdio
Task providerbuild / run / test / check wired to verum with the $verum problem matcher.VS Code task API
Terminal linksfile.vr:42:10 in any terminal becomes a clickable link.VS Code terminal-link API

Activation​

The extension activates on any of:

  • Opening a .vr file (onLanguage:verum).
  • Opening a workspace that contains verum.toml or any .vr file.
  • Starting a debug session of type: verum.

On activation the extension spawns:

${verum.lsp.serverPath} lsp --transport stdio

and keeps the client alive for the life of the window. The first .vr you open is analyzed as a module. Later edits produce versioned analysis; imported types and whole-project contracts require a project check.

Explore architecture​

Open Verum: Show Architecture to inspect the active file's declarations, explicit context requirements, imports and diagnostics. The tree uses the same verum/documentSnapshot response as Studio, with no second parser in the extension. Selecting an item navigates to its source range.

A snapshot must match the open buffer's URI, version and source hash. Editing, closing or switching documents clears stale entries; late responses cannot restore them. This is a source-level view of Architecture as Type, not a proof of runtime behavior or complete cross-module analysis. Update the verum binary alongside the extension to provide this protocol.

Cursor refinement actions are explicit and require saved source. Results and suggested edits are checked against the document revision before display or application. The four validation outcomes are valid, invalid, unknown and not applicable; an empty diagnostics list is never labelled as verified. See verification outcomes for the precise boundary.

Commands​

All commands live under the Verum category (Ctrl/Cmd-Shift-P):

CommandDefault bindingEffect
Verum: Run Current FileCmd+Shift+Rverum run <file> in an editor terminal.
Verum: Run Test—verum test <file> --filter <fn> at the cursor.
Verum: Verify Function Contracts—Function-wide contract verification is not exposed by the language server; use the compiler proof workflow.
Verum: Show Escape Analysis—Show the CBGR escape-analysis report for the & sigil at the cursor. Re-dispatches to editor.action.showHover; the hover bubble already contains the structured markdown (tier, mutability, escape verdict, promotion availability). Emitted by the LSP code-action "View escape analysis details".
Verum: Promote to &checked ReferenceCmd+Alt+CAsk the server to upgrade &T → &checked T with proof comment.
Verum: Add Runtime Check (Result<T, E>)—Wrap in a runtime fallback when escape-analysis fails.
Verum: Infer Refinement TypeCmd+Alt+RAsk the server for a refinement suggestion for the symbol at cursor.
Verum: Validate Refinement at CursorCmd+Alt+VOne-shot SMT validation of the refinement at the cursor.
Verum: Profile Current File—Run profiling; results populate the dashboard.
Verum: Open Profile Dashboard—Focus the explorer-pane webview.
Verum: Restart Language Server—Kill and respawn verum lsp.
Verum: Show Language Server Status—Current state + crash count.
Verum: Format DocumentCmd+Shift+FDelegates to LSP formatter.

The supported verum/* JSON-RPC methods backing language inspection are shared with Studio; the server routes them through LspService.build(...).custom_method(...). The SMT layer is isolated behind a dedicated verum-smt-worker OS thread so the handler futures are Send — see LSP → Custom verum/* JSON-RPC methods — architecture for the full call path.

Configuration​

The extension reads settings under verum.*. The defaults match the recommendations in CLI and LSP.

LSP​

SettingDefaultMeaning
verum.lsp.enabletrueMaster switch.
verum.lsp.serverPath"verum"Path to the verum binary.
verum.lsp.validationMode"quick"quick (100 ms deadline) / thorough (1 s) / complete (configured timeout).
verum.lsp.enableRefinementValidationtrueEnable explicit cursor refinement validation; standard compiler diagnostics remain independent.
verum.lsp.showCounterexamplestrueAttach concrete witness values to refinement errors.
verum.lsp.showInlayHintstrueInline inferred types and CBGR tiers.
verum.lsp.diagnosticDelay200 msDebounce for refreshing the architecture view after an edit.
verum.lsp.smtSolver"auto"auto / z3 / cvc5. The cursor-validation worker uses Z3; CVC5 is reported as inconclusive.
verum.lsp.smtTimeout50 msPer-obligation SMT timeout for live validation (build-time timeout is separate; see verum.toml [verify] solver_timeout_ms).
verum.lsp.cacheValidationResultstrueCache cursor results by source content, position, mode and configuration.
verum.lsp.cacheTtlSeconds300Cache entry TTL. The server hot-swaps capacity/TTL on workspace/didChangeConfiguration — no restart.
verum.lsp.cacheMaxEntries1000Cache capacity. On downsize, oldest entries are evicted.
verum.lsp.maxCounterexampleTraces5Max execution-trace steps attached to a counter-example.
verum.lsp.trace.server"off"messages / verbose dumps LSP traffic to the output channel.

CBGR​

SettingDefaultMeaning
verum.cbgr.enableProfilingfalseEnable CBGR per-deref profiling (≈ 1.5 ns per check, measured).
verum.cbgr.showOptimizationHintsfalseOpt-in inlay hints on every & reference — compact badges (0ns for promotable, ~1.5ns for CBGR-tier-0, nothing on &checked / &unsafe). Skipped in type positions (fn f(p: &T)). Off by default; the hover bubble already shows this information on demand.

Verification​

SettingDefaultMeaning
verum.verification.showCostWarningstrueWarn when a single obligation exceeds the slow threshold.
verum.verification.slowThresholdMs5000Slow-verification threshold.

Code lens / formatting / debug​

SettingDefaultMeaning
verum.codeLens.enabletrueAll code lenses on/off.
verum.codeLens.showRunButtontrue"▶ Run" above fn main.
verum.codeLens.showTestButtontrue"▶ Test" above @test fn.
verum.codeLens.showReferencestrueReference count above every top-level symbol.
verum.formatting.enabletrueFormat on save.
verum.semanticHighlighting.enabletrueUse LSP semantic tokens on top of TextMate.
verum.debug.defaultTier"interpreter"interpreter (VBC, full step/breakpoint support) or aot (LLVM, reduced).
verum.debug.dapServerPath""Override the DAP server path; empty falls back to verum.lsp.serverPath.

Settings changes are forwarded live via workspace/didChangeConfiguration — no restart needed for any of them.

Syntax-highlighting model​

The grammar is grammar-driven: every keyword, literal form, and attribute shape in the EBNF specification has a corresponding TextMate pattern. Key points:

  • Keywords. All four tiers — reserved (let / fn / is), primary (type / where / using), control-flow, async, proof — are matched exhaustively. Rust-style struct / enum / trait / impl / ref / move / drop are not Verum syntax and are not highlighted.
  • Strings. Triple-quoted """...""" (always raw, always multiline), byte strings b"...", interpolated f"..." / f"""...""" (with {expr:format} format-spec scope inside), character literals 'x'.
  • Tagged literals. sql#"""...""" and its ~40 format-tag friends (json, json5, yaml, toml, xml, html, csv, rx, url, d, dur, ip, b64, hex, sh, css, lua, asm, …) with language-specific embedded scopes where it makes sense, plus ${expr} interpolation.
  • Refinement predicates. The { self > 0 && self <= 100 } shape after a type reference is detected heuristically and scoped as meta.refinement.verum, with self highlighted as a language variable.
  • Attributes. @derive(A, B) highlights each derivee; @verify(formal) validates against the 13 strategies in the grammar; @name(args) gets generic parameter/value scopes.
  • No #[...]. Verum uses @ exclusively; there are no Rust-style hash attributes.
  • No name! macros. Verum has no macro-bang syntax — compile-time constructs all use @ (@derive, @const, @cfg, @sql_query, user-defined @my_macro).

Snippets cheatsheet​

The most common prefixes:

PrefixExpands to
fnFunction definition
fn-verify-formal@verify(formal) fn ... requires ... ensures ...
fn-throwsFunction with typed error boundary
fn-usingFunction with using [Context] clause
typeType alias
type-refinedRefinement type (Int { self > 0 })
type-record / type-variantRecord / sum type
type-newtypeOpaque wrapper (type X is (Int);)
protocoltype X is protocol { ... }
impl / impl-generic / impl-whereimplement [Proto] for Type forms
mount / mount-items / mount-as / mount-globModule imports
match-maybe / match-resultPattern-match on Maybe<T> / Result<T, E>
try / try-finally / try-fullError handling blocks
defer / errdeferScoped cleanup
async-fn / spawn / nursery / selectAsync / structured concurrency
ref-checked / ref-unsafeCBGR tier sigils
theorem / lemma / proof / calc / forall / existsProof constructs
sql / rx / json / html / url / dateTagged literal scaffolds
fstring / fstring-multi / raw-stringString literal shapes

Debugging​

The extension ships a VS Code debug configuration type verum. Press F5 inside any .vr file to launch the default config:

{
"type": "verum",
"request": "launch",
"name": "Debug Verum Program",
"program": "${file}",
"stopOnEntry": false,
"tier": "interpreter"
}

tier: "interpreter" runs the program through the VBC interpreter with full DAP support (step-into, step-over, breakpoints, variable inspection). tier: "aot" links native and exposes a reduced breakpoint set. The initial configuration palette provides three scaffolds: Debug Current File, Debug with Arguments, Debug (Stop on Entry).

Tasks​

The extension registers a verum task type. In .vscode/tasks.json:

{
"type": "verum",
"task": "build", // build | run | test | check
"problemMatcher": ["$verum"]
}

The $verum problem matcher parses error[V####]: … / --> file.vr:L:C outputs and surfaces them as diagnostics in the Problems panel.

Troubleshooting​

Status bar shows Verum: Error​

The LSP server failed to start. Check the Verum Language Server output channel for the actual stderr. Most likely causes:

  • verum not on $PATH — fix verum.lsp.serverPath.
  • verum version too old for the grammar in your file — re-download the binary from GitHub Releases and replace /usr/local/bin/verum.
  • Corporate VPN rewrites certificates — unrelated; LSP uses stdio.

verum.lsp.smtSolver set to smt-backend produces different results from auto​

Expected — auto races available solver adapters according to the goal shape. Prefer auto for correctness-critical work and smt-backend only when reproducing a specific solver's trace. See Verification / SMT routing.

@verify(formal) obligations time out while typing​

verum.lsp.validationMode defaults to quick (≤ 100 ms budget). For hot files you're actively proving, bump to thorough — it accepts a 1 s ceiling and retries with a different tactic. For full solver budgets, verify at build time via verum check rather than on-type.

"Cannot promote: escape analysis could not prove safety"​

Verum: Promote to &checked Reference asks the compiler to upgrade a CBGR reference to the zero-cost tier. If the escape analysis can't prove that the reference is stack-local, the promotion is refused. Use Verum: Add Runtime Check (Result<T, E>) instead, which wraps the deref in a fallible result.

See also​

  • LSP — the protocol-level feature set the extension surfaces.
  • CLI — the commands invoked by task / run / test / debug actions.
  • Installation — install the verum binary the extension drives.
  • Studio — graphical workspace using the shared language service.