Language Server Development

Document Synchronization

The LSP tracks document changes using incremental synchronization:

textDocument/didOpen
Document opened in editor
textDocument/didChange
Document content changed (incremental deltas sent)
textDocument/didClose
Document closed

This ensures the LSP always has the current document state while minimizing data transfer.

Durability and Invalidation Policy

Panache uses Salsa durability levels to reduce unnecessary revalidation work in LSP mode.

Durability assignments

LOW
Open-buffer text updates (didOpen, didChange) for the active document.
MEDIUM
Per-document config updates and file-watcher refreshes for already cached dependency files.
HIGH
Disk-loaded dependency files cached from the project graph.

Invalidation policy

  • Edits while typing should invalidate low-durability data aggressively, but should not force broad revalidation of stable dependency data.
  • Config reloads and watcher events use medium durability so changes propagate, but with less churn than open-buffer edits.
  • Disk-cached dependencies use high durability so unrelated low-frequency edits do not repeatedly revalidate those inputs.

Verification and measurement

  • Durability revalidation measurement harness: tests/durability_bench.rs (ignored by default).

  • Run with:

    cargo test --test durability_bench durability_revalidation_bench -- --ignored --nocapture
  • Policy regression tests are in src/salsa.rs and validate that high-durability stable inputs avoid revalidation under low-durability updates, while low-durability stable inputs are revalidated.