Skip to content

Editor support — Zed

.strategy files get syntax highlighting and the same live validation as VS Code through the repo's Zed extension (editors/zed-strategy).

Zed does not support TextMate grammars, so the extension ships its own tree-sitter grammar (editors/tree-sitter-strategy). Validation still uses dio strategy lsp, the minimal Language Server Protocol server built into the engine (src/engine/strategies/harness/strategy_lsp.ml). It runs the same parser and validator as dio strategy validate, so diagnostics match the engine.

1. Build dio

dune build
# binary: _build/default/bin/main.exe

2. Install the extension

editors/zed-strategy/dev-install.sh

The script:

  1. snapshots editors/tree-sitter-strategy into a throwaway git repo,
  2. builds editors/zed-strategy to wasm32-wasip2,
  3. compiles the tree-sitter parser with wasi-sdk,
  4. symlinks the extension into Zed's extensions/installed directory.

The first run downloads wasi-sdk (about 180 MB) unless it is already present or WASI_SDK_PATH is set. Requirements: Rust with the wasm32-wasip2 target, python3, rsync, curl, and tar.

After changing the extension, grammar, or queries, re-run the script. Zed reloads dev extensions automatically; if it does not, run cmd-shift-p → zed: reload extensions.

3. Point the server at the binary

The extension resolves dio in this order:

Order Location
1 dio on PATH
2 <worktree>/_build/default/bin/main.exe

So a fresh dune build in this repo is enough. Elsewhere, put dio on PATH. If neither exists, Zed shows the missing path in its language-server error notification; highlighting still works.

4. Using it

Open a *.strategy file. Highlighting is immediate; validation appears as you type. Diagnostics carry the validator's message, for example step ev_cancelled: unknown action: apply_order_evet, and parse errors point at the exact line and column.

The grammar is intentionally flat: it tokenizes the language for highlighting and bracket matching but does not model indentation-scoped blocks. Structural outline and indent features are therefore limited; dio strategy validate remains the authoritative check before restarting the engine.

Troubleshooting

  • No highlighting: check zed: open log for failed to load language Strategy. Re-run dev-install.sh after editing the grammar.
  • No diagnostics: confirm _build/default/bin/main.exe strategy lsp exists (or dio is on PATH), then run zed: restart language server from the command palette.
  • LSP protocol smoke test:
    python3 editors/zed-strategy/tests/lsp_smoke.py