# Zed extension

> The Elide extension for Zed: `elide lsp` as a Java language server, an Elide debug adapter for JavaScript, TypeScript and Python, and debugging from Zed tasks.

The [Elide extension for Zed](https://github.com/elide-dev/zed) adds `elide lsp` as a Java language server and an
`Elide` debug adapter for JavaScript, TypeScript and Python. Any Zed task that runs `elide run` or `elide test` also
shows up in the debugger's **Debug** tab.

## Requirements

| Requirement | Why |
| --- | --- |
| Elide 1.6.0 or newer on `PATH` | The extension runs `elide`; set another path in settings. |
| Zed's [Java extension](https://github.com/zed-extensions/java) | It defines the Java language. |
| The [Pkl extension](https://github.com/Moshyfawn/pkl-zed) | Highlights `elide.pkl`. Optional. |
| `elide setup python` | Only to debug Python. |

## Install

Install it as a dev extension, which needs Rust through `rustup`:

```bash
git clone https://github.com/elide-dev/zed elide-zed
```

In Zed, open **Extensions**, choose **Install Dev Extension** and select the `elide-zed` directory.

## Java language server

Name `elide` in the Java `language_servers` list of `settings.json`. To use it instead of jdtls:

```json
{
  "languages": {
    "Java": { "language_servers": ["elide", "!jdtls", "..."] }
  }
}
```

`["elide", "jdtls"]` keeps both; `["!elide", "..."]` turns Elide off. The server reads the workspace root Zed sends,
and an `elide.pkl` there makes it an Elide project, so dependencies resolve. It provides diagnostics, completion,
hover, navigation, rename, formatting, code actions, inlay hints and semantic tokens; see
[Other editors](https://elide.help/docs/connect-ide#java-language-server) for the full list.

To run a specific binary or pass extra flags:

```json
{
  "lsp": {
    "elide": {
      "binary": { "path": "/opt/elide/bin/elide", "arguments": ["lsp"] }
    }
  }
}
```

`arguments` replaces the default `["lsp"]`.

## Debugging

Open the debugger with `debugger: start` (F4) and pick a scenario from `.zed/debug.json`, a task from the **Debug**
tab, or **Launch** with the `Elide` adapter. `launch` starts `elide run --debugger=dap` (or `elide test` with
`"command": "test"`) and connects; `attach` connects to a program already listening:

```json
[
  { "label": "Debug app.ts", "adapter": "Elide", "request": "launch", "program": "app.ts" },
  { "label": "Debug this file", "adapter": "Elide", "request": "launch", "program": "$ZED_FILE" },
  { "label": "Debug tests", "adapter": "Elide", "request": "launch", "command": "test", "args": ["app.test.ts"] },
  { "label": "Attach", "adapter": "Elide", "request": "attach", "tcp_connection": { "host": "127.0.0.1", "port": 4711 } }
]
```

| Launch field | Meaning |
| --- | --- |
| `program` | File to run, relative to `cwd`. |
| `args` | Arguments after `program`. |
| `cwd` | Working directory; defaults to the worktree root. |
| `env` | Extra environment variables. |
| `command` | `run` (default) or `test`. |
| `elideArgs` | Elide flags before `program`, such as `["--max-mem=512m"]`. |
| `host`, `port` | DAP listener; defaults to `127.0.0.1` and a free port (`4711` to attach). |

Program output appears in the debug console. To attach, start the program yourself:

```bash
elide run --debugger=dap app.py
```

To make Elide the default debugger for a language's gutter and new-process modal:

```json
{ "languages": { "TypeScript": { "debuggers": ["Elide"] } } }
```

### Limits

- Java and Kotlin debugging (JDWP) isn't offered: Zed debugs Java only through the Java extension.

## Related

- [IDE integration](https://elide.help/docs/ide): what each editor gets.
- [Other editors](https://elide.help/docs/connect-ide): `elide lsp` and DAP from Neovim, Helix and other clients.
- [Debugging](https://elide.help/docs/debugging): CDP, DAP and JDWP debuggers for every language.
