Language Server Protocol (LSP) Contract
Status
- Type: Normative
- Stability: Draft
Design Principles
- The Rust server is the single source of truth for analysis and diagnostics.
- The VS Code extension should be a thin LSP client.
- Custom behaviors MUST be documented and versioned.
FerroTeX provides:
- Source analysis features derived from parsing and indexing LaTeX documents.
- Build observability features derived from TeX engine output and
.logparsing.
Baseline Capabilities (Required for MVP)
The server SHOULD implement:
textDocument/didOpen,didChange,didSave,didClosetextDocument/publishDiagnosticsworkspace/executeCommand
Optional enhancements:
textDocument/hoverfor diagnostic provenancetextDocument/codeActionfor fix suggestions
Industry-Standard Language Feature Set (Target)
The following capabilities represent the target feature set expected of mature language tooling.
Document Intelligence
textDocument/documentSymbol(outline)textDocument/foldingRangetextDocument/documentLink(navigate\\input,\\include,\\includegraphics, bibliography resources)textDocument/selectionRange
Navigation
textDocument/definitiontextDocument/referencestextDocument/rename(labels, bib keys, local command/environment definitions where safe)workspace/symbol
Rename MUST be safety-gated:
- labels are supported
- citations MAY be supported when keys are known and edits are unambiguous
- command/environment rename MUST be refused unless the server can prove the definition/reference set is safe
Authoring
textDocument/completion(commands, environments, packages, labels, citations)textDocument/signatureHelp(macro argument hints where inferable)
Semantics and Rendering
textDocument/semanticTokens(full/delta)textDocument/hover(symbol info + provenance)
Formatting
textDocument/formattingtextDocument/rangeFormatting
Quality-of-Life
textDocument/codeAction(quick fixes, refactors)textDocument/codeLens(optional; e.g., reference counts for labels)
Workspace and Lifecycle
workspace/didChangeConfigurationworkspace/didChangeWatchedFiles- Cancellation support for long-running requests
Source vs Build Diagnostics
FerroTeX may publish diagnostics from multiple producers:
- Source diagnostics: syntax recovery errors, unresolved references, duplicate labels, invalid citation keys, etc.
- Build diagnostics: TeX engine errors and warnings, derived from
.logparsing.
Diagnostics SHOULD set source = "ferrotex" and use stable codes (see diagnostic-codes.md).
Commands
Commands are namespaced:
ferrotex.compileferrotex.cleanferrotex.reparseLogferrotex.openLogExcerpt
Additional commands (target):
ferrotex.indexWorkspace-
ferrotex.openProjectGraph ferrotex.openOutputferrotex.forwardSearch
Each command MUST specify:
- parameters
- side effects
- expected error states
Diagnostic Payload
Diagnostics MUST include:
- severity
- message
- range (best-effort)
Diagnostics SHOULD include:
code(stable identifier)source = "ferrotex"relatedInformationcontaining provenance
Confidence SHOULD be surfaced via:
Diagnostic.codeDescription(URL) ORDiagnostic.datavia a custom extension (editor-dependent)
Incremental Updates
The server SHOULD publish diagnostics:
- on compilation completion
- during streaming compilation when stable
The server MUST avoid flapping:
- partial parses should not cause frequent large-scale remapping unless confidence justifies it
Configuration
Configuration keys are documented in configuration.md.
The server MUST react to configuration changes without requiring restart when feasible.
File Watching
The server SHOULD handle:
workspace/didChangeWatchedFiles
to support incremental invalidation and reindexing (see file-watching.md).