Syntax highlighting, formatting, diagnostics, and snippets for
Wax (a Rust-like syntax for WebAssembly) in
.wax files and for WebAssembly text (.wat) files.
Features
- Formatting with the Wax formatter itself, compiled to WebAssembly and run
in-process, so it works the same in desktop and web VS Code with no separate
install. Run "Format Document", or turn on "Format on Save"
(
editor.formatOnSave). Files with syntax errors are left untouched. - Diagnostics as you type: syntax errors, type errors, and lints from the same toolchain are shown inline (squiggles) and in the Problems panel.
- Hover types (
.wax): hover over an expression to see its inferred type, read straight off the type-checker's typed tree. Hovering a name that is not an expression shows what it resolves to instead — a type reference shows the type's definition, an assignment target or global shows its type. Works mid-edit through the recovering parser even while other parts of the file have errors. - Inlay hints (
.wax): the inferred type is shown inline on each un-annotatedletbinding (e.g.let x = 3displaysx: i32). Toggle them with theeditor.inlayHints.enabledsetting. - Go to definition (
.wax): jump from a use to its definition — a function, global, type, or tag; alet/parameter binding; or a block/loop label. Works through shadowing (a use resolves to the binding actually in scope). - Go to type definition (
.wax): from a value, jump to the declaration of its type — e.g. from a variable of type&pointtotype point = { … }. - Find all references / highlight (
.wax): from a use or a definition, list every occurrence of the symbol (Shift+F12), and highlight them in the file when the cursor is on one. - Rename (
.wax): rename a symbol (F2) across all its occurrences, resolving through shadowing. A punned struct field is expanded ({p| x}becomes{p| x: new}) so the struct's field is left intact; rename is declined when the cursor is not on a renameable symbol. - Completion (
.wax): suggests the names in scope — the module's functions, globals, types, and tags, the enclosing function's parameters and locals, and keywords — and, after., the fields of a struct value (including chains likel.a.x) plus the value methods for the receiver (clz/sqrt/… on a number,length/fill/… on an array, the SIMD ops on av128, the load/store/management ops on a memory or table); after::, an intrinsic namespace's functions (v128::,i64::,atomic::). Suggestions respect conditional compilation and thewax.defineconfiguration, so a definition in a branch the defines rule out is not offered. Works while the file is mid-edit. - Signature help (
.wax): while typing a call, shows the callee's signature with the active argument highlighted — for functions, imported functions,ns::intrinsics, and methods (x.min(…),mem.load8(…)). - Semantic highlighting (
.wax): colours identifiers by role — functions, parameters, locals/globals, types (including references like&point), struct fields, and intrinsic namespaces — refining the grammar's coarser colouring. - Expand / shrink selection (
.wax): Shift+Alt+→ grows the selection along the syntax tree — identifier, expression, statement, block, function, whole file — and Shift+Alt+← shrinks it back. Works mid-edit through the recovering parser. - Code folding (
.wax): fold block bodies (functions,if/loop/while/match/tryblocks),#[if]/#[else]branches, and multi-line block comments, from the parse tree rather than by indentation. - Conditional-compilation dimming (
.wax): setwax.define(e.g.["debug=true", "arch=wasm64"], mirroring the-Dflag) and the#[if]/#[else]branches that configuration makes unreachable are dimmed as dead code, like a preprocessor greying out inactive#ifdefregions. A status-bar item shows the active defines and edits them in a click. Diagnostics specialize to the same configuration (likewax -D … check), so a type error that lives only in a branch the defines rule out is not reported. - Convert / preview: "Wax: Show compiled WAT" (in a
.waxfile) opens the compiled WebAssembly text in a read-only document beside the source, updating live as you edit; "Wax: Show as Wax" does the reverse from a.watfile. Both are on the editor toolbar and in the command palette. - WebAssembly text (
.wat): the same features apply to.watfiles too: formatting, diagnostics, document outline, syntax highlighting, snippets, and comment/bracket handling, all from the same in-process toolchain and grammar. - Syntax highlighting via a TextMate grammar covering the full language:
keywords and control flow (
fn,let,do,loop,match,dispatch,try/catch, thebr*branch family, stack-switching, …), primitive and abstract heap types, references, numeric/char/string literals with escapes, labels ('label), attributes (#[export = …],#[if(…)],#[likely], …), aggregate literals ({point| …},[bytes| …]), qualified intrinsics (v128::const_i32x4,i64::add128), and method-style intrinsics. - Language configuration: line/block comments, bracket matching and colorization, auto-closing pairs, and indentation rules. Single quotes are intentionally not auto-closed, because they introduce labels.
- Snippets for common constructs (functions, imports/exports, control flow, types, tags, memories).