Repository navigation
LSP
Curlee ships a deterministic Language Server Protocol (LSP) server over stdio.
Curlee currently commits to these LSP features:
-
textDocument/publishDiagnostics(parse/type/resolve diagnostics on open/change) textDocument/hovertextDocument/definition-
textDocument/completion(baseline) -
textDocument/rename(baseline workspace edits) -
textDocument/semanticTokens/full(baseline legend + full-document tokens) -
textDocument/codeAction(baseline)
Capabilities advertised by initialize are intentionally minimal and stable for v1:
-
textDocumentSync = 1(full-document sync) hoverProvider = truedefinitionProvider = true-
completionProviderpresent (resolveProvider = false) renameProvider = true-
semanticTokensProviderpresent (with stable legend) codeActionProvider = true
Current legend order is stable and used for token type indexes:
keywordfunctionvariabletypenumberstring
LSP diagnostics are published with stable machine-readable metadata:
source: "curlee"code: "curlee.diagnostic"data.schema: "curlee.diag.v1"data.file: <source path>-
data.span: {start,end}byte offsets when available (ornull)
LSP diagnostics also include the standard LSP range (line/character) derived from the same source span.
CLI JSON diagnostics continue to publish byte offsets (span.start, span.end) so both surfaces are aligned on underlying span coordinates.
curlee fmt is the supported formatter entrypoint for v1.
v1 policy:
- Formatting output for supported inputs is intended to be stable across v1 patch/minor releases.
- Formatting is idempotent: formatting an already-formatted file should not change it.
-
curlee fmt --checkis the compatibility-safe CI mode:- exits non-zero when formatting changes are needed,
- exits zero when the file is already in canonical format.
If formatter output needs to change in a user-visible way, that should be treated as a compatibility-affecting change and called out in release notes.
Validated workflow for a typical editor integration:
- Send
initializeand cache capabilities. - Send
textDocument/didOpenwith full file text. - Consume
textDocument/publishDiagnosticsnotifications. - Request language features as needed:
textDocument/hovertextDocument/definitiontextDocument/completiontextDocument/renametextDocument/semanticTokens/fulltextDocument/codeAction
- Send
textDocument/didChange(full-document sync mode), then consume refreshed diagnostics.
This workflow is exercised by in-repo tests:
curlee_lsp_internal_testscurlee_lsp_hover_golden_tests
Curlee currently uses full-document sync (textDocumentSync = 1) and re-checks on change.
For editor responsiveness, the current baseline budget is:
-
curlee checkaverage wall time for representative passing samples should stay at or under0.20s.
Validation command:
python3 scripts/benchmark.py --curlee build/linux-debug/curlee --runs 5 --dirs tests/runLatest validation snapshot:
samples=8 runs=5 avg_seconds=0.0788
This keeps the current baseline comfortably within budget.
- Hovering an expression shows its inferred type.
- Hovering a function call shows the callee signature, its
requiresclauses, parameter refinements, and a short obligations summary (instantiated at the call site when possible).
cmake --preset linux-debug
cmake --build --preset linux-debug --target curlee_lspThe server speaks LSP over stdio:
./build/linux-debug/curlee_lspConfigure your editor to launch the executable above as an LSP server.
- Start the server in a terminal:
./build/linux-debug/curlee_lsp
- Send an
initializerequest over stdin:Content-Length: 65 {"jsonrpc":"2.0","id":1,"method":"initialize","params":{}} - Open a Curlee document:
Content-Length: 142 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///tmp/test.curlee","text":"fn main() { return 1 + 2; }"}}} - Request hover:
Content-Length: 136 {"jsonrpc":"2.0","id":2,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///tmp/test.curlee"},"position":{"line":0,"character":20}}}
You should receive JSON-RPC responses with capability info (see Glossary), diagnostics, and hover content.