# VS Code Extension

> Sync, run and debug Elide projects in Visual Studio Code.

## Requirements

- VS Code 1.105 or newer.
- Elide installed ([Installation](https://elide.help/docs/installation)).
- The **Kotlin by JetBrains** extension (`JetBrains.kotlin-server`). It installs automatically; finish its one-time
  setup prompt.
- A separate JDK for code intelligence, set with `elide.jdk.home` or `$JAVA_HOME`.

## Install

```bash
curl -LOJ "https://plugins.elide.dev/vscode/files?id=elide.elide"
code --install-extension elide-*.vsix
```

## Sync a project

Opening a folder with `elide.pkl` syncs it into `workspace.json`, which the Kotlin extension reads. Add
`workspace.json` to `.gitignore`. Click the **Elide** status bar item to sync again.

| Status bar | Meaning |
| --- | --- |
| **Elide** with a check | In sync |
| **Elide** with a spinner | Syncing |
| **Elide: out of date** | `elide.pkl` changed; click to sync |
| **Elide**, error-colored | Sync failed; click to retry, or run **Elide: Show Output** |

If the folder also has `.idea`, set `"intellij.buildTool": "json"` in `.vscode/settings.json` so the Kotlin extension
reads `workspace.json`.

## Run

| Command | Effect |
| --- | --- |
| `Elide: Sync Project(s)` | Sync again. |
| `Elide: Run Elide Command…` | Run `build`, `test`, `install`, or `run <entrypoint>` as a task. |
| `Elide: Show Output` | Show CLI output and the sync log. |

Tasks use type `elide`:

```jsonc
{ "type": "elide", "command": "test", "args": ["-t", "MyTest"] }
```

`command` is `build`, `run`, `test` or `install`; `args` follow the command; `project` picks a project root.

## Debug

```jsonc
{
  "type": "elide",
  "request": "launch",
  "name": "Elide: Run (debug)",
  "entrypoint": "src/main.kt"
}
```

Without `entrypoint`, the manifest's `entrypoint` or `jvm.main` runs. `args`, `env` and `project` are optional.
`elide.debug.adapter` picks the debugger: `intellij` (default, from the Kotlin extension) or `java` (install
[Debugger for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug)).
To debug tests, see [Debugging](https://elide.help/docs/debugging#debug-tests).

## Settings

| Setting | Default | Effect |
| --- | --- | --- |
| `elide.home` | `""` | Elide install root. Empty: `$ELIDE_HOME`, install locations, then `elide` on `PATH`. |
| `elide.jdk.home` | `""` | JDK for code intelligence. Empty: `jvm.javaHome`, `$JAVA_HOME`, a JDK for `jvm.target`. |
| `elide.sync.onStartup` | `true` | Sync when the workspace opens. |
| `elide.sync.onManifestChange` | `"prompt"` | `always`, `prompt` or `never`. |
| `elide.kotlinLsp.writeWorkspaceJson` | `true` | Write `workspace.json`. |
| `elide.debug.adapter` | `"intellij"` | `intellij` or `java`. |
