# oxyaml for Zed

Zed extension for [oxyaml](https://github.com/marwanvx/oxyaml), a fast YAML language server and JSON Schema validator.

## Install

Once listed, open **Extensions** in Zed, search for **oxyaml**, and click **Install**.
The first YAML session downloads a binary from the latest stable [oxyaml release](https://github.com/marwanvx/oxyaml/releases).
Zed shows installation progress. The extension checks the extracted binary's size, caches it by
release, and removes older copies after a successful install. It can reuse the cached binary when
GitHub is unavailable.

Automatic downloads support x86-64 and ARM64 on Linux, macOS and Windows. Linux prefers the
musl build for portability and falls back to GNU if the release lacks a musl asset.

## Configuration

In Zed's `settings.json`, make oxyaml the default YAML server and move any existing
`lsp.yaml-language-server.settings` to `lsp.oxyaml.settings`.

```json
{
  "languages": {
    "YAML": {
      "language_servers": ["oxyaml", "!yaml-language-server", "..."]
    }
  },
  "lsp": {
    "oxyaml": {
      "settings": {
        "yaml": {
          "keyOrdering": true,
          "format": {
            "singleQuote": true
          },
          "schemas": {
            "https://getcomposer.org/schema.json": ["composer.yaml"],
            "kubernetes": ["k8s/**/*.yaml"]
          }
        }
      }
    }
  }
}
```

oxyaml handles plain YAML, GitHub Actions workflows, Docker Compose files, and Kubernetes
manifests. The server loads schemas from SchemaStore or the configured associations.
This example assigns the Kubernetes schema to files under `k8s/`. Open Helm-rendered YAML
to validate the resulting manifests.

The `settings.yaml` object supplies the `yaml` section of `workspace/configuration`.
Use `lsp.oxyaml.initialization_options` for options sent with `initialize`.
To prefer a binary on the worktree's PATH, add `"use_system_binary": true` inside
`lsp.oxyaml.settings`, alongside `yaml`. Automatic installation is the fallback.

## Local development

Run these checks from `editors/zed`.

```sh
rustup target add wasm32-wasip2
cargo fmt --check
cargo clippy --locked --all-targets -- -D warnings
cargo test --locked
cargo build --locked --target wasm32-wasip2 --release
```

In Zed, run **Extensions: Install Dev Extension**, select `editors/zed`, and apply the
configuration above. Set `use_system_binary` to use a local build. Open `composer.yaml` with
`name: 42` and check for a schema type diagnostic. Change the value to a string and confirm the
diagnostic clears. After a stable release is available, repeat on a clean profile using the
managed binary. Restart Zed to verify cache reuse.
