Skip to content

Add position encoding negotiation support#4

Merged
christiankissig merged 1 commit into
masterfrom
add-position-encoding
Jun 3, 2026
Merged

Add position encoding negotiation support#4
christiankissig merged 1 commit into
masterfrom
add-position-encoding

Conversation

@christiankissig

Copy link
Copy Markdown
Owner

Summary

Adds support for position encoding negotiation as introduced in LSP 3.17 — Text Documents.

Prior to 3.17, all positions (column offsets) were assumed to be UTF-16 code units. Since 3.17 the client and server can agree on a different encoding:

  • The client advertises supported encodings (in decreasing preference) via the general.positionEncodings capability.
  • The server reports the encoding it picked via the positionEncoding server capability. If there is no match, UTF-16 is the mandatory default.

Changes

  • PositionEncodingKind — string enum with utf-8 / utf-16 / utf-32, matching the spec's base type.
  • GeneralClientCapabilities — new model exposing positionEncodings (plus the other general sub-capabilities); wired into ClientCapabilities.general (previously a bare dict).
  • ServerCapabilities — new model carrying the negotiated positionEncoding.
  • New names exported from lsp_client.

Testing

  • 6 new tests covering the enum values, client advertisement, InitializeRequest wire output, and the server capability.
  • poetry run pytest (38 passed), ruff check, ruff format --check, and mypy all clean.

🤖 Generated with Claude Code

LSP 3.17 lets the client and server negotiate how positions are
encoded (what column offsets mean), rather than always assuming UTF-16.

- Add PositionEncodingKind (utf-8 / utf-16 / utf-32) per the spec's
  base type.
- Add GeneralClientCapabilities so clients can advertise supported
  encodings via general.positionEncodings, wired into ClientCapabilities.
- Add ServerCapabilities carrying the server-chosen positionEncoding.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@christiankissig christiankissig merged commit b95a1d9 into master Jun 3, 2026
7 checks passed
@christiankissig christiankissig deleted the add-position-encoding branch June 3, 2026 17:10
christiankissig added a commit that referenced this pull request Jul 7, 2026
Add position encoding negotiation support
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