# LSP guide
## Scope
Manages language servers and collects diagnostics after document edits.
## Where to look
| Shared types and limits | `mod.rs` |
| Server reuse, failure isolation, idle shutdown | `manager.rs` |
| Initialization, document sync, fresh diagnostics | `client.rs` |
| Framed process transport | `stdio.rs` |
| Language routing and document versions | `sync.rs` |
| Diagnostic freshness and injection format | `diagnostics.rs` |
## Local rules
- Reuse the manager's configured workspace/server routing. A diagnostic request must not expand the editing tool's file access.
- Preserve document version tracking on full-document synchronization. Versioned diagnostics must meet the requested version; unversioned diagnostics must arrive after synchronization started.
- Inject only selected error/warning diagnostics through the existing count/byte limits and redaction formatter.
- Keep initialization/request waits and cancellation in the blocking transport/client path; do not wait for a language server on the UI thread.
- Preserve idle shutdown and repeated-failure disabling in the manager. An unavailable server should not be presented as a successful clean diagnostic check.
- Keep LSP Content-Length framing separate from MCP's newline-delimited stdio protocol; shutdown must still release child processes.