Language-feature requests: typed params/results + request-response correlation#14
Merged
Merged
Conversation
…orrelation Implements #13. Request/response correlation (client.py): - Track in-flight requests in a dict[id, asyncio.Future]. - New `request()` coroutine awaits a response result, correlating by id, raising `LSPError` on a ResponseError and TimeoutError (after sending `$/cancelRequest`) on timeout. Configurable via `request_timeout`. - New `cancel_request()` sends a spec-correct `$/cancelRequest` notification. - `_handle_response` resolves/rejects the matching future and forwards server-initiated and unmatched messages to `response_handler`. Typed params (protocol.py): - New `DocumentSymbolRequest` / `DocumentHighlightRequest`. - Hover/Completion/Definition accept typed params models or a raw dict. - `CompletionParams` with optional `CompletionContext`. Result models + union parsers (protocol.py): - Hover, Completion, Definition, DocumentSymbol, DocumentHighlight models per LSP 3.17, plus five `parse_*_result` helpers that validate and normalise each runtime union. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
christiankissig
added a commit
that referenced
this pull request
Jul 7, 2026
Language-feature requests: typed params/results + request-response correlation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #13 — the general LSP pieces downstream clients need for language features (hover, completion, definition, documentSymbol, documentHighlight).
1. Request/response correlation (
client.py)LSPClienttracks in-flight requests in_pending_requests: dict[id, asyncio.Future].request(request, timeout=...)coroutine sends a request and awaits itsresult, correlating the response byid. RaisesLSPErroron aResponseError; on timeout it fires$/cancelRequestand raisesasyncio.TimeoutError.cancel_request(id)sends a spec-correct$/cancelRequestnotification (no top-levelid)._handle_responseresolves/rejects the matching future and still forwards server-initiated requests, notifications, and unmatched responses to the existingresponse_handler.request_timeouton__init__/from_command.send_requeststays fire-and-forget for backward compatibility.2. Request types + typed params (
protocol.py)DocumentSymbolRequestandDocumentHighlightRequest._coerce_paramshelper — existing dict-based callers are unaffected.CompletionParamswith optionalCompletionContext { triggerKind, triggerCharacter? }.3. Result models + union parsers (
protocol.py)Hover,MarkupContent,MarkupKind,MarkedString.CompletionList,CompletionItem,CompletionItemKind,InsertTextFormat,TextEdit,InsertReplaceEdit,CompletionTriggerKind.LocationLink(alongside existingLocation).DocumentSymbol(recursive),SymbolInformation,SymbolKind,SymbolTag.DocumentHighlight,DocumentHighlightKind.parse_*_resulthelpers that validate and normalise each runtime union (bareCompletionItem[]→CompletionList, singleLocation→[Location],LocationLinkvsLocationbytargetUri,DocumentSymbolvsSymbolInformationbylocation).All new names are exported from
lsp_client/__init__.py.Acceptance
awaita typed, validated result (orNone).Checks
poetry run pytest— 101 passedpoetry run ruff check ./ruff format --check .— cleanpoetry run mypy .— clean🤖 Generated with Claude Code