Editor setup
Get errors, hover, completion and formatting for Sakura Lang in VS Code and other editors, through the compiler's language server.
Your editor talks to the compiler you installed, through sakura lsp. So the errors in your
editor are exactly the ones sakura check prints.
Build the extension from source
The VS Code extension is not on the VS Code Marketplace or Open VSX yet. Build it from the
repository as shown below. It needs a sakura command from Install or a
source build.
VS Code
You need Bun and a clone of the repository:
cd sakuralang/editors/vscode
bun install --frozen-lockfile
bun run package
code --install-extension sakura-0.1.0-alpha.1.vsixThen open a folder that contains a project (a folder with a sakura.toml). That's all.
The same .vsix also installs in editors built on VS Code that accept local extensions, such
as Cursor and VSCodium.
If the extension cannot find sakura
The extension uses the first sakura on your PATH. If yours is somewhere else, set
sakura.path:
{
"sakura.path": "~/.cargo/bin/sakura"
}The server starts as soon as you save the setting; no reload needed. Without a compiler, the extension shows an error that links to the install instructions.
The extension starts one server per project, in the nearest folder above the file that holds a
sakura.toml. A workspace with several projects checks each one separately.
What you get
- Errors as you type, including in files you have not opened. Each error code links to
its error page, for example
V1004to/docs/errors/V1004. - Quick fixes that show how big a change they make, such as
Use `List` (impact: local). A fix that would change a contract or widen access says so before you apply it. If the file changed since the fix was computed, it is refused; ask for it again. - Formatting on save, with
sakura fmt's rules. To turn it off, set"[sakura]": { "editor.formatOnSave": false }. - Show Hole Context, from the command palette or by right-clicking in a
.sakfile. It shows the typed hole (a?nameplaceholder) at the cursor as JSON: the expected type, effects, local variables and candidates. It is the same record the MCPhole_contexttool returns. - Highlighting, comment toggling, bracket matching and auto-closing pairs.
Other editors
Any editor with an LSP client works. Run sakura lsp, with no arguments, in the project
folder. Details for client authors:
- The server reads its project from the first workspace folder.
- It prefers UTF-8 positions and falls back to UTF-16.
- It answers
sakura/holeContext(with atextDocumentand aposition) with the hole record. - Diagnostics carry a
codeDescriptionlink. Quick fixes carry their impact indata.impactand, when the client supportsdocumentChanges, the document version they were computed for.
Tree-sitter
editors/tree-sitter-sakura
is a Tree-sitter grammar with Rust and Node bindings, plus queries for highlighting, locals,
indentation and SQL/HTML injection. Neither binding is published; the README there lists
build steps and where it differs from the compiler's parser, which stays authoritative. VS
Code still uses its TextMate grammar, and the Tree-sitter grammar adds no LSP features.
Stability
The language server's standard features (document sync, diagnostics, hover, definition,
completion, formatting and code actions, over stdio) are stable from
v1.0.0-beta.1 under RFC 0001. The sakura/holeContext request and
the extra fields in a diagnostic's or fix's data are experimental. The VS Code extension
and the Tree-sitter grammar are not published and carry no promise.
Last updated
Why Sakura Lang
Why agent-written code is hard to review, how putting the facts in the signature helps, and how Sakura Lang compares with languages you know.
Build and deploy a server
Scaffold an HTTP service, test its routes without a socket, run it under its manifest's grants, then ship it in a container.