Roux.Lang.LSP (roux v0.2.2)

Copy Markdown View Source

Generic LSP server that delegates IDE features to query-based language implementations. Built on gen_lsp.

The server owns a Roux.Database for its session lifetime. IDE features (diagnostics, hover, completions, go-to-definition) become queries in the same database, sharing cached intermediate results with compilation.

Configuration

config :roux,
  languages: [MyLang]

File synchronization

Uses full-text sync (TextDocumentSyncKind.full()). Each didOpen/didChange notification sets the source text as an input via Roux.Input.set/4, which triggers incremental recomputation. Stale in-flight tasks are cancelled via Roux.Cancellation.cancel_dependents/2. Diagnostics are pushed after a configurable debounce period.

Durability limitation

The subsystem spec describes per-key durability transitions (:low while editing, :medium on save/close). Roux.Input.set/4 uses the durability from the input definition, not per-call overrides, so per-key transitions are not yet supported. didClose restores disk content but does not change durability. didSave is a no-op. See the spec's note: "the full durability model may need per-key durability tracking."

Position mapping

LSP uses 0-based {line, character} positions. Roux languages use 1-based {line, column}. The adapter handles conversion at the boundary. Languages can use roux_position_to_lsp/1 when building response ranges.

Summary

Functions

Converts a Roux 1-based position to an LSP 0-based position struct.

Functions

child_spec(opts)

roux_position_to_lsp(arg)

@spec roux_position_to_lsp({pos_integer(), pos_integer()}) ::
  GenLSP.Structures.Position.t()

Converts a Roux 1-based position to an LSP 0-based position struct.

Languages implementing hover or definition queries can use this to build LSP-compatible response ranges.

start_link(opts)

@spec start_link(keyword()) :: {:ok, pid()} | {:error, term()}