lsp-llm 0.2.1

Opt-in LLM advisor for axon-lsp, gated behind the `llm` Cargo feature. Never on the critical path: deterministic capabilities (diagnostics, hover, completion) work without this crate.
Documentation
# axon-lsp

Language Server Protocol implementation for the
[Axon](https://github.com/Bemarking/axon-lang) programming language.
A single Rust binary that speaks LSP and, by construction, works in
**VSCode, Claude Code, Cursor, Antigravity, Zed, Neovim** —
or anything else that speaks LSP — with no per-IDE work.

> **Status: v0.2.0 released** — published on crates.io with
> `axon-frontend = "0.3"` as a registry dep. Roadmap and Resultado
> blocks for every sub-fase live in
> [`docs/plan_v0.2.0.md`]docs/plan_v0.2.0.md (the v0.1.0 plan
> sits in [`docs/plan_v0.1.0.md`]docs/plan_v0.1.0.md for history).
> Install via `cargo install axon-lsp`, download from
> [GitHub Releases]https://github.com/Bemarking/axon-lsp/releases,
> install the [VSCode extension]editors/vscode/, or build from
> source — see [docs/integrations/install.md]docs/integrations/install.md.

## What it does

| Capability | Behavior |
|---|---|
| `publishDiagnostics` | Lex / parse / type errors with `axon-{lex,parse,type}` source tag and precise ranges (whole identifier for type errors, single char for punctuation) |
| `hover` | Markdown — local declarations show kind + signature; outer doc comments (`///`, `/** */`) attached to channel decls render as a Markdown paragraph above the signature; built-in types (`String`, `Channel`, `Trusted`, …) and syntax keywords pull rich docs from the embedded corpus |
| `definition` | Zero-width Location at the declaration's keyword |
| `documentSymbol` | Outline tree with sensible `SymbolKind` per declaration kind |
| `completion` | Context-aware: inside a type annotation surfaces only types, in declaration name slots stays out of the way, default context offers keyword snippets + user decls + built-in types with `lsp-docs` documentation attached |
| `references` | File-local + workspace-wide. Walks every TypeExpr-bearing site (type field types, flow params, return types, intent output types) with `Loc`-precise ranges; cross-file scan reads in-memory snapshots first, falls back to disk parses |
| `prepareRename` + `rename` | Workspace-wide atomic `WorkspaceEdit`. D8 rejections pinned in code: built-in types, declaration keywords, stdlib symbols, and identifiers absent from the workspace index reject with stable user-facing messages |
| `documentSymbol` + `workspace/symbol` | The latter is a substring-match query against an index of every `name → DeclLocation` the server has seen in any `.axon` file under workspace folders |
| `semanticTokens/full` | LSP standard registry mapping — types, functions, variables, parameters, properties, decl keywords, with `declaration` / `readonly` modifiers. The TextMate grammar still paints lexical concerns (strings, numbers, regular comments) so the two layers don't double-paint |
| `inlayHint` | Inferred type after `let` literal RHS — `: String`, `: Integer`, `: Float`, `: Bool`. Range filter respected so off-screen lines don't ship hints |
| `codeAction` | Two quick fixes (kind = `quickfix`): **Rename to typo candidate** (Levenshtein-≤2 search across the workspace decl name set on `Undefined <kind> 'NAME' …` diagnostics, up to 3 candidates) and **Insert missing `}`** (zero-width insertion on `Expected RBrace, found …`) |
| `formatting` | Token-level passthrough through the [`axon-fmt`]crates/axon-fmt/ crate. Right-trims trailing whitespace per line + ensures exactly one trailing `\n`. Comments survive verbatim across all six kinds (`//`, `/* */`, `///`, `/** */`, `//!`, `/*! */`) thanks to the Fase 14 trivia channel. Mirrors `axon fmt` in `axon-lang` v1.9.0+ for byte-identical output |
| `axon/askAdvisor` (opt-in) | Custom LSP method backed by Anthropic's Messages API. Two-axis gate: build with `--features llm` AND set `AXON_LSP_LLM_ENABLED=1` + `ANTHROPIC_API_KEY=…`. Default builds reply with `MethodNotFound`; the deterministic stack is unaffected by either gate. |

## Editor integrations

Single binary, every editor. Pick yours and follow the doc:

- **VSCode**[docs/integrations/vscode.md]docs/integrations/vscode.md
  ([extension source]editors/vscode/)
- **Cursor**[docs/integrations/cursor.md]docs/integrations/cursor.md
- **Antigravity**[docs/integrations/antigravity.md]docs/integrations/antigravity.md
- **Zed**[docs/integrations/zed.md]docs/integrations/zed.md
- **Neovim**[docs/integrations/neovim.md]docs/integrations/neovim.md
- **Claude Code**[docs/integrations/claude-code.md]docs/integrations/claude-code.md

[`docs/integrations/README.md`](docs/integrations/README.md) carries
the index plus the canonical 4-check smoke-test program every editor
must light up.

## Architecture

```
crates/
  axon-lsp/   # binary, tower-lsp bootstrap + every LSP handler
  lsp-core/   # logic — pure, sync, no I/O
              #   document.rs (rope), diagnostics.rs (range scanner),
              #   hover.rs, definition.rs, completion.rs (context heuristic),
              #   symbols.rs (DeclMeta + outline), text.rs (shared helpers),
              #   frontend.rs (axon-frontend shim),
              #   workspace.rs (cross-file decl index), references.rs,
              #   rename.rs, semantic_tokens.rs, inlay_hints.rs,
              #   code_actions.rs, formatting.rs (axon-fmt shim)
  axon-fmt/   # token-level lossless formatter, consumed by `lsp-core`
              # via workspace dep + invoked by `textDocument/formatting`.
              # Mirrors `axon fmt` in `axon-lang` v1.9.0+
  lsp-docs/   # 18+ Markdown entries embedded at compile time via build.rs;
              # zero runtime deps, lookups hit `&'static str` slices
  lsp-llm/    # opt-in advisor, feature = "llm";
              # default builds keep `reqwest` out of the binary entirely
              # — pinned by an executable smoke test that scans the
              # release binary for forbidden symbol bytes
editors/
  vscode/     # TypeScript extension; spawns the binary, attaches
              # the editor's selection as advisor context, ships
              # commands + snippets
docs/
  plan_v0.2.0.md       # the live roadmap + Resultado blocks (current)
  plan_v0.1.0.md       # historical, kept for traceability
  fase_14_lossless_lexing.md  # upstream reference doc for the
                               # trivia channel `axon-fmt` consumes
  style.md             # canonical Axon style — what the formatter
                       # changes (and what it deliberately doesn't)
  integrations/        # one self-contained doc per editor
```

`lsp-core` and `lsp-docs` keep `cargo tree --edges normal` empty of
`tokio / axum / sqlx / aws-* / reqwest / hyper / jsonwebtoken` —
verified in CI on every commit. The Fase 12.c contract (frontend with
zero runtime deps) holds end-to-end into the LSP binary.

## Build

Rust **1.95.0 stable** (pinned by `rust-toolchain.toml`).

```sh
cargo build --workspace --release
cargo test --workspace
```

The advisor crate is excluded from the default build:

```sh
cargo build --workspace --release --features axon-lsp/llm
```

## Releases

[Releases page](https://github.com/Bemarking/axon-lsp/releases)
publishes:

- 3 platform archives (`linux-x86_64`, `macos-arm64`,
  `windows-x86_64`) — one binary each.
- `SHA256SUMS` — combined integrity-verification list.

macOS Intel (`x86_64-apple-darwin`) builds from source
(`cargo install axon-lsp`) until a cross-compiled / self-hosted
target lands in a later release.

Auto-generated release notes summarise the commits since the
previous tag. The full `v0.1.0` story lives in
[`CHANGELOG.md`](CHANGELOG.md) and the per-sub-fase Resultado blocks
in [`docs/plan_v0.1.0.md`](docs/plan_v0.1.0.md).

## Contributing

`axon-lsp` is **adopter-agnostic** — it serves the Axon language the
same way `rust-analyzer` serves Rust. No customer or tenant names
appear in code, tests, fixtures, or docs. Details in
[`CONTRIBUTING.md`](CONTRIBUTING.md).

## License

MIT — see [`LICENSE`](LICENSE).