# Editor setup

URL: /docs/editors
Markdown: /docs/editors.md

> Use Sakura Lang in VS Code (and editors built on it) through the compiler's language server, sakura lsp.

> **Pre-alpha: install from source**
>
> The VS Code extension is not on the VS Code Marketplace or Open VSX yet. Build it from the repository as below; it needs a `sakura` executable from the [quickstart](/docs/quickstart#install-from-source).

The editor support is the compiler's own language server, `sakura lsp`, over stdio. The VS Code extension in [`editors/vscode/`](https://github.com/icantcodefyi/sakuralang/tree/master/editors/vscode) is a thin client for it: diagnostics, hover, definitions, completion, formatting and quick fixes come from the compiler you installed, so the editor and `sakura check` always agree.

## VS Code [#vs-code]

Build and install the extension from a checkout. You need [Bun](https://bun.sh):

```bash
cd sakuralang/editors/vscode
bun install --frozen-lockfile
bun run package
code --install-extension sakura-0.1.0-alpha.1.vsix
```

Open a folder that contains a project (a `sakura.toml`). The extension starts `sakura lsp` once per project, in the nearest directory above the file that holds a `sakura.toml`, so a workspace with several projects checks each separately.

It finds the compiler through the `sakura.path` setting, or the first `sakura` on `PATH` when the setting is empty. Without one it shows an error with a link to the install instructions; set the path and the server starts without a reload.

```json title=".vscode/settings.json"
{
  "sakura.path": "~/.cargo/bin/sakura"
}
```

The same `.vsix` installs in editors built on VS Code that accept local extensions, such as Cursor and VSCodium.

## What it shows [#what-it-shows]

- **Diagnostics** as you type, including files you have not opened. The error code in each one links to its [error page](/docs/errors), for example `V1004` to `/docs/errors/V1004`.
- **Quick fixes** with their impact class in the title, such as ``Use `List` (impact: local)``. Fixes that change a contract or an authority say so before you apply them. A fix computed before the file last changed is refused rather than applied to the wrong text; ask for it again.
- **Formatting** with `sakura fmt`'s rules, on save by default. Turn it off with `"[sakura]": { "editor.formatOnSave": false }`.
- **Show Hole Context** (command palette, or right-click in a `.sakura` file): the [typed hole](/docs/agents/typed-holes) at the cursor as JSON, the same record the MCP `hole_context` tool returns: expected type, effects, locals and candidates.
- **Highlighting** from the grammar this site uses, plus comment toggling, bracket matching and auto-closing pairs.

## Other editors [#other-editors]

Any editor with an LSP client can run `sakura lsp` with no arguments in the project directory. The server takes its project from the first workspace folder, prefers UTF-8 positions and falls back to UTF-16, and answers `sakura/holeContext` (a `textDocument` and `position`) with the hole record. Diagnostics carry a `codeDescription` link; quick fixes carry their impact class in `data.impact` and, when the client supports `documentChanges`, the document version they were computed for.
