Axle v0.14.1

Editor support

Axle ships a language server (axle-lsp) and an official VS Code extension. Together they give you syntax highlighting, type-aware hover, goto-definition, find references, rename, contextual completion, inline diagnostics, code actions, and one-click axle build / axle run tasks.

Any editor that speaks the Language Server Protocol can drive axle-lsp directly — VS Code is the one with the polished client.

VS Code

Install

  1. Install the axle compiler — see Install the compiler. The axle-lsp binary ships in the same package, next to axle.
  2. Install the extension from the VS Code Marketplace (search for “Axle”) or sideload a .vsix built from source.

Once both pieces are in place, opening any .axle file activates the extension automatically. The status bar in the bottom-left shows the server state:

BadgeMeaning
$(loading~spin) AxleThe language server is starting.
$(check) AxleRunning — hover the badge for the version.
$(error) AxleStopped or crashed — click to restart.

What you get

FeatureWhat it does
Semantic highlightingPer-identifier colouring driven by the language server. In Console::println("hi") it colours the Console namespace and the println method, never the parens or the string argument. Classes, traits, enums, enum members and namespaces each get their own scope so the theme can colour them distinctly.
Contextual completionAfter . you only see fields and methods of the receiver type. After :: you see enum variants or module exports. After use std:: you walk the stdlib path tree. In a type position (let x :, fn f(x :) you only see types — never statement keywords like if or let.
HoverThe expression’s type plus a kind classification, the symbol’s doc-comment (yours or the stdlib’s), and — on locals and parameters — a memory-behaviour summary: which storage tier the compiler chose, the ownership contract, whether the binding is reassigned.
Goto definitionLands on the declaration head — class Foo, fn bar, the original let x = … for a local, the Variant in an enum declaration — across project files. Go to Type Definition and Go to Implementations (trait → implementing classes) work too.
Find referencesLocals, parameters, and free functions — across project files.
RenameLocals, parameters, and free functions, project-wide: the edit touches every file that references the symbol.
Document outlineTree of every class, struct, trait, enum, and free function in the current file — navigable through Outline: view and Ctrl+Shift+O.
Workspace symbolsSubstring search via Ctrl+T — covers the whole project once any of its files is open.
Inline diagnosticsLexing, parsing, and semantic errors with hint lines. Each error keeps its catalogue code (E0014, E0511, …) so you can cross-reference Reading compiler errors.
Editor lintsUnused variables / parameters are greyed out; a let that’s never reassigned gets a “consider const” hint — both with one-click fixes.
Signature helpThe current call’s parameter list as you type, with the active parameter highlighted.
Code actionsQuick-fix lightbulbs: “did you mean …?” on a typo (E0002), auto-use insertion for stdlib types, let → const.
Folding & smart selectFold functions, types and blocks; Shift+Alt+→ expands the selection through enclosing expressions.
Inlay hintsInferred types beside let bindings without an explicit type annotation. Toggle them off with axle.inlayHints.enable if you find them noisy.
Snippetsfn main, class, try / catch, defer, spawn / join, @vectorize / @unroll loops, extern "C" fn, struct literal, multi-arm match, generic class / function, doc-comment template, …
Tasksaxle: build, axle: run, axle: check, axle: bench, axle: profile are surfaced under “Tasks: Run Task”. Ctrl+Shift+B runs axle build ${file} by default.
CodeLensAn “N references” lens above each function, and an “N implementors” lens above each class or trait; clicking one lists the locations. Toggle with axle.codeLens.enable.

Settings

All keys live under the axle.* prefix in your settings.json.

Server lifecycle (changes restart the server) :

SettingDefaultEffect
axle.server.pathaxle-lspPath to the binary. Accepts ~, ${workspaceFolder}, or a bare name resolved through PATH.
axle.server.extraArgs[]Extra CLI args passed when spawning the server.
axle.server.env{}Extra environment variables — useful for RUST_LOG.
axle.trace.serveroffLSP-trace level (off / messages / verbose).

Live filters (applied without restart) :

SettingDefaultEffect
axle.inlayHints.enabletrueMaster switch for inlay hints.
axle.inlayHints.typeAnnotationstrueInferred types beside let.
axle.inlayHints.parameterNamestrueParameter names at call sites.
axle.semanticHighlighting.enabletrueUse the server’s precise tokens. Disabling falls back to grammar-only highlighting.
axle.completion.snippetstrueInclude snippet items in completion proposals.
axle.codeLens.enabletrueShow the server’s code lenses. Toggle at runtime with the Axle: Toggle Code Lens command.

Toggled at extension start :

SettingDefaultEffect
axle.tasks.enabletrueRegister the axle build / run / check / bench / profile tasks.
axle.statusBar.enabletrueShow the Axle status-bar item.

Customising colours

The extension ships defaults that work with VS Code’s built-in Dark+ and Light+ themes. To override the colour of any token type (in any theme), add to your settings.json:

"editor.semanticTokenColorCustomizations": {
    "rules": {
        "class:axle":      { "foreground": "#FFD580", "bold": true },
        "interface:axle":  { "foreground": "#C9A0DC", "italic": true },
        "enum:axle":       { "foreground": "#A8E6CF" },
        "enumMember:axle": { "foreground": "#FFB6C1" },
        "namespace:axle":  { "foreground": "#87CEEB" }
    }
}

Every token type you can target, scoped to Axle with :axle : namespace, class, interface, enum, enumMember, type, typeParameter, function, method, parameter, variable, property, keyword, string, number.

Tasks

Ctrl+Shift+P → "Tasks: Run Task" lists five tasks under the axle provider:

TaskCommand
axle: buildaxle build ${file}
axle: runaxle run ${file}
axle: checkaxle check ${file}
axle: benchaxle bench ${file}
axle: profileaxle profile ${file}

You can also write project-local tasks in tasks.json:

{
    "type": "axle",
    "command": "build",
    "args": ["-O", "3"],
    "file": "${workspaceFolder}/src/main.axle",
    "label": "axle: release build"
}

The axle binary is resolved as the sibling of axle.server.path (the apt / Docker packaging ships them together) or falls back to bare axle on PATH.

Snippets

Type the prefix and hit Tab. The most-used ones:

PrefixExpands to
mainfn main() : i32 { … return 0; }
fnfn name(args) : void { … }
classClass with one field + constructor
gclassGeneric class skeleton
structStruct declaration
slitStruct literal Type { field: value }
if / ifeif (cond) { … } / if … else …
forfor (i of 0..n) { … }
match / matchmTwo-arm / multi-arm match
trytry { … } catch e : Exception { … }
deferdefer cleanup();
spawnlet t : Task<T> = spawn work(args);, then let r : T = t.join();
docDoc-comment skeleton
externextern "C" fn under its own symbol name
externas@link(…) + extern "C" fn, when the names differ
useuse std::…;
printlnConsole::println(value);

Other editors

Any LSP-aware editor can drive axle-lsp directly. The general recipe is:

  1. Make sure axle-lsp is on your PATH (it ships with axle).
  2. Configure the editor to launch axle-lsp on stdio for files whose extension is .axle or whose language id is axle.

The protocol speaks plain LSP — no custom extensions, no proprietary methods. Semantic-token rendering depends on the editor mapping the 15 token types the server advertises (namespace, class, interface, enum, enumMember, type, typeParameter, function, method, parameter, variable, property, keyword, string, number) to its theme. The VS Code extension does this through semanticTokenScopes; other editors typically need a few lines of configuration to point each token type at the right theme colour.

A TextMate grammar ships with the VS Code extension as a syntax-only fallback for editors without an LSP client; it can be copied into any editor that consumes the TextMate format.

Known limitations

The language server is pre-1.0. A few rough edges :

  • Semantic-token colours on non-ASCII lines. Highlighting may paint slightly shifted on a line containing multi-byte characters before the token. Diagnostics, hover and navigation are not affected.
  • Rename targets. Methods, fields, and type names refuse the rename with an explanatory message — locals, parameters and free functions are the supported targets.
  • Sibling edits propagate on save. Other project files are read from disk; an unsaved change in file B becomes visible to file A when B is saved.

See also

lspeditorvscodetooling