Converts between Minga's byte-indexed positions and LSP positions.
LSP historically uses UTF-16 code unit offsets for character positions, a legacy of the JavaScript/TypeScript origins. Modern servers support UTF-8 offset encoding via capability negotiation in LSP 3.17+.
The conversion implementation lives in Minga.Core.PositionEncoding so pure diagnostics and other Layer 0 modules can use the same rules without depending on LSP services.
Summary
Types
The negotiated offset encoding for a server session.
Functions
Returns the LSP encoding strings for capability advertisement.
Converts an LSP position map back to a Minga {line, byte_col} tuple.
Negotiates the best offset encoding from the server's supported list.
Converts a Minga {line, byte_col} position to an LSP position map.
Types
@type encoding() :: Minga.Core.PositionEncoding.encoding()
The negotiated offset encoding for a server session.
Functions
@spec client_supported_encodings() :: [String.t()]
Returns the LSP encoding strings for capability advertisement.
@spec from_lsp(map(), String.t(), encoding()) :: {non_neg_integer(), non_neg_integer()}
Converts an LSP position map back to a Minga {line, byte_col} tuple.
Negotiates the best offset encoding from the server's supported list.
Prefers UTF-8, then UTF-16, then UTF-32. Falls back to UTF-16 if the server does not advertise support.
@spec to_lsp({non_neg_integer(), non_neg_integer()}, String.t(), encoding()) :: map()
Converts a Minga {line, byte_col} position to an LSP position map.