neoclide/coc.nvim · error · Error
Unsupported position encoding (${result.capabilities.positio
Error message
Unsupported position encoding (${result.capabilities.positionEncoding}) received from server ${this.name} What it means
During doInitialize, the client validates the server's InitializeResult: any server that advertises a positionEncoding other than UTF-16 is rejected with this error. The client (like vscode) only supports UTF-16 position encoding, so a server claiming 'utf-8' or 'utf-32' capability is incompatible.
Source
Thrown at src/language-client/client.ts:1228
const part = new ProgressPart(connection, token)
part.begin({ title: `Initializing ${this.id}`, kind: 'begin' })
return this.doInitialize(connection, initParams).then(result => {
part.done()
return result
}, (error: Error) => {
part.done()
return Promise.reject(error)
})
} else {
return this.doInitialize(connection, initParams)
}
}
private async doInitialize(connection: Connection, initParams: InitializeParams): Promise<InitializeResult> {
try {
const result = await connection.initialize(initParams)
if (result.capabilities.positionEncoding !== undefined && result.capabilities.positionEncoding !== PositionEncodingKind.UTF16) {
throw new Error(`Unsupported position encoding (${result.capabilities.positionEncoding}) received from server ${this.name}`)
}
this._initializeResult = result
this.$state = ClientState.Running
let textDocumentSyncOptions: TextDocumentSyncOptions | undefined
if (Is.number(result.capabilities.textDocumentSync)) {
if (result.capabilities.textDocumentSync === TextDocumentSyncKind.None) {
textDocumentSyncOptions = {
openClose: false,
change: TextDocumentSyncKind.None,
save: undefined
}
} else {
textDocumentSyncOptions = {
openClose: true,
change: result.capabilities.textDocumentSync,
save: {
includeText: falseView on GitHub (pinned to 50e974d969)
Solutions
- Configure the server to use UTF-16 offsets (e.g. rust-analyzer: {"lsp":{"positionEncoding":"utf-16"}} or {"offsetEncoding":["utf-16"]}).
- Downgrade or switch to a server build that doesn't force utf-8 position encoding.
- Update coc.nvim — newer versions may support more encodings.
- If the server has no encoding option, open an issue upstream or use an alternative server.
Example fix
// before (rust-analyzer config)
{ "rust-analyzer.lsp.enable": true } // server defaults to utf-8
// after (settings.json of the server)
// ~/.config/rust-analyzer/settings.json or RA args
{ "lsp": { "positionEncoding": "utf-16" } } Defensive patterns
Strategy: validation
Type guard
function supportsUtf16(initResult: InitializeResult): boolean {
const enc = initResult.capabilities.positionEncoding
return enc === undefined || enc === 1 /* PositionEncodingKind.UTF16 */
} Try / catch
try {
await client.start()
} catch (e) {
if (String(e).includes('Unsupported position encoding')) {
// reconfigure the server to utf-16 or switch servers
}
} Prevention
- Configure servers to use UTF-16 position encoding (rust-analyzer: positionEncoding/offsetEncoding utf-16).
- Check the server's LSP version support before adopting 3.17-era servers.
- Keep coc.nvim updated for any broadened encoding support.
- Test new servers with a minimal config before wiring them into your setup.
When it happens
Trigger: Connecting to a language server whose capabilities.positionEncoding is set to UTF-8 or UTF-32 (per LSP 3.17 spec) — e.g. servers using rust-analyzer's lsp-server crate or other toolkits defaulting to utf-8; server built against newer LSP features while client pins UTF-16.
Common situations: Using a cutting-edge server (rust-analyzer with utf-8 position encoding enabled, newer jdtls/helix-ecosystem servers) with coc.nvim; server config enabling `positionEncoding: utf-8` / `offsetEncoding`; LSP 3.17 servers under vim clients that don't negotiate encoding.
Related errors
- Language server ${id} not found
- ${uri} changed before apply edit
- Unable to getCallHierarchyItem at current position
- Action "${action.title}" is disabled: ${action.disabled.reas
- Format provider not found for buffer: ${doc.bufnr}
AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31).
Data as JSON: /api/errors/e48f7c663a91ffee.
Report an issue: GitHub.