Skip to content

Expand ServerCapabilities to the full spec field set#11

Merged
christiankissig merged 1 commit into
masterfrom
expand-server-capabilities
Jun 3, 2026
Merged

Expand ServerCapabilities to the full spec field set#11
christiankissig merged 1 commit into
masterfrom
expand-server-capabilities

Conversation

@christiankissig

Copy link
Copy Markdown
Owner

Summary

Fleshes out ServerCapabilities per LSP 3.17 — Initialize. It previously exposed only positionEncoding; this adds the full documented set of provider/capability fields returned in the InitializeResult.

Changes

  • ServerCapabilities now includes every field from the spec: textDocumentSync, notebookDocumentSync, completionProvider, hoverProvider, signatureHelpProvider, the goto providers (declaration/definition/typeDefinition/implementation), referencesProvider, documentHighlightProvider, documentSymbolProvider, codeActionProvider, codeLensProvider, documentLinkProvider, colorProvider, formatting providers, renameProvider, foldingRangeProvider, executeCommandProvider, selectionRangeProvider, linkedEditingRangeProvider, callHierarchyProvider, semanticTokensProvider, monikerProvider, typeHierarchyProvider, inlineValueProvider, inlayHintProvider, diagnosticProvider, workspaceSymbolProvider, workspace, and experimental.
  • TextDocumentSyncKind enum added (None_=0, Full=1, Incremental=2), used by textDocumentSync.

Typing convention

Consistent with the rest of protocol.py (where nested capability structures are dict | None):

  • fields the spec models as boolean | XxxOptionsbool | dict | None,
  • fields that are only XxxOptions / XxxRegistrationOptionsdict | None,
  • textDocumentSyncTextDocumentSyncKind | dict | None.

All fields default to None, so the existing minimal-ServerCapabilities behaviour (and model_dump(exclude_none=True)) is unchanged — fully backward compatible.

Testing

  • 4 new tests: TextDocumentSyncKind values, mixed provider serialisation (enum + bool + options dicts), textDocumentSync as an options object, and parsing a realistic server response payload via model_validate.
  • poetry run pytest (75 passed), ruff check, ruff format --check, and mypy all clean.

🤖 Generated with Claude Code

ServerCapabilities previously exposed only positionEncoding. Add the
documented provider/capability fields from the LSP initialize spec:
sync, completion, hover, definition, references, formatting, rename,
code actions/lens, semantic tokens, diagnostics, workspace, experimental
and the rest. Following this module's convention, dedicated XxxOptions
objects are typed as dict and `boolean | XxxOptions` unions as bool|dict.
Also add the TextDocumentSyncKind enum used by textDocumentSync.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@christiankissig christiankissig merged commit d1dc457 into master Jun 3, 2026
7 checks passed
@christiankissig christiankissig deleted the expand-server-capabilities branch June 3, 2026 20:32
christiankissig added a commit that referenced this pull request Jul 7, 2026
Expand ServerCapabilities to the full spec field set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant