
Vary has a VS Code extension with syntax highlighting, a language server (hover, go-to-definition, completions, formatting, rename, semantic tokens), and format-on-save.

> **Note:** The Vary extension is not yet published to the VS Code marketplace. Install it from the `.vsix` file bundled with every toolchain.

## Install the extension

The `.vsix` file is included in every Vary toolchain under `vscode-vary/`. If you installed Vary with [varyup](/docs/varyup/), use it to install the extension:

```bash
varyup vscode install
```

This finds the `.vsix` in the active toolchain and runs `code --install-extension` automatically. If `code` is not on your PATH, it prints the `.vsix` path so you can install manually.

To get the `.vsix` path for scripting:

```bash
varyup which vsix
```

### Manual install

If you are not using varyup, install the extension directly:

```bash
# Linux
code --install-extension /path/to/vary/vscode-vary/varylang-*.vsix --force

# Windows
code --install-extension "$HOME\path\to\vary\vscode-vary\varylang-*.vsix" --force
```

After installing or updating the extension, reload VS Code (`Ctrl+Shift+P` > "Developer: Reload Window").

Make sure `vary` is on your `PATH`. The extension starts the language server automatically when you open a `.vary` file.

## Dev Containers

Dev Containers run the compiler, language server, and extension inside a Docker container. This works on Windows, macOS, and Linux without installing Vary locally.

**Prerequisites:** [Docker Desktop](https://www.docker.com/products/docker-desktop/) (Windows/macOS) or Docker Engine (Linux), and the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).

| Step | Action |
|------|--------|
| 1 | Open a Vary project that has a `.devcontainer/devcontainer.json` (create one with `vary new my-app --devcontainer`) |
| 2 | Press `Ctrl+Shift+P` and select **Dev Containers: Reopen in Container** |
| 3 | The container has the Vary CLI, the LSP server, and the extension already configured |

No manual extension installation or PATH setup is needed inside the container.

## What you get

| Feature | How |
|---------|-----|
| Syntax highlighting | TextMate grammar, works out of the box |
| Hover information | LSP: type info, documentation, and check rule explanations |
| Go to definition | LSP: `F12` or `Ctrl+Click` |
| Completions | LSP: variables, functions, modules |
| Format on save | LSP: set `vary.format.onSave` to `true` |
| Rename symbol | LSP: `F2` |
| Semantic tokens | LSP: type-aware highlighting |
| Diagnostics | LSP: errors, warnings, and check findings with guidance text |
| Code actions | LSP: quick-fixes for check rule violations |

## Configuration

| Setting | Default | Description |
|---------|---------|-------------|
| `vary.lsp.path` | `"vary"` | Path to the Vary CLI binary |
| `vary.lsp.args` | `["lsp"]` | Arguments to start the language server |
| `vary.lsp.trace.server` | `"off"` | Trace level for LSP communication (`off`, `messages`, `verbose`) |
| `vary.format.onSave` | `false` | Automatically format `.vary` files on save |

## VS Code Tasks

Projects created with `vary new` include `.vscode/tasks.json` with these tasks:

```bash
vary check src/           # Vary: Check
vary test test/            # Vary: Test
vary fmt src/              # Vary: Format
vary mutate src/ --tests test/  # Vary: Mutate
```

Run them from **Terminal > Run Task** or `Ctrl+Shift+P` > **Tasks: Run Task**.
