Sakura Lang

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.vsix

Then 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:

.vscode/settings.json
{
  "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 V1004 to /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 .sak file. It shows the typed hole (a ?name placeholder) at the cursor as JSON: the expected type, effects, local variables and candidates. It is the same record the MCP hole_context tool 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 a textDocument and a position) with the hole record.
  • Diagnostics carry a codeDescription link. Quick fixes carry their impact in data.impact and, when the client supports documentChanges, 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.

Edit on GitHub

Last updated

On this page