{"record":{"id":"1e0a213adb332e1d","repo":"neoclide/coc.nvim","slug":"semantictokens-provider-not-found-for-this-doc-u","errorCode":null,"errorMessage":"SemanticTokens provider not found for ${this.doc.uri}","messagePattern":"SemanticTokens provider not found for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/handler/semanticTokens/buffer.ts","lineNumber":219,"sourceCode":"  private get buffer(): Buffer {\n    return this.nvim.createBuffer(this.bufnr)\n  }\n\n  public get enabled(): boolean {\n    if (!this.configEnabled || !this.hasLegend) return false\n    return this.hasProvider\n  }\n\n  private get shouldHighlight(): boolean {\n    if (!this.enabled) return false\n    const { doc } = this\n    if (doc.dirty || doc.version === this._version) return false\n    return true\n  }\n\n  public checkState(): void {\n    if (!this.configEnabled) throw new Error(`Semantic tokens highlight not enabled for current filetype: ${this.doc.filetype}`)\n    if (!this.hasProvider || !this.hasLegend) throw new Error(`SemanticTokens provider not found for ${this.doc.uri}`)\n  }\n\n  public async getTokenRanges(\n    tokens: number[],\n    legend: SemanticTokensLegend,\n    token: CancellationToken): Promise<SemanticTokenRange[] | null> {\n    let currentLine = 0\n    let currentCharacter = 0\n    let highlights: SemanticTokenRange[] = []\n    let toBytes: (characterIndex: number) => number | undefined\n    let textDocument = this.doc.textDocument\n    let tickStart = Date.now()\n    for (let i = 0; i < tokens.length; i += 5) {\n      if (i == 0 || Date.now() - tickStart > yieldEveryMilliseconds) {\n        await waitImmediate()\n        if (token.isCancellationRequested) break\n        tickStart = Date.now()\n      }","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/handler/semanticTokens/buffer.ts#L201-L237","documentation":"checkState throws this when the semantic tokens configuration is enabled for the filetype, but the buffer either has no attached server that registers a SemanticTokens provider (hasProvider false) or the server did not register the token legend needed to decode token types (hasLegend false).","triggerScenarios":"Semantic highlight enabled for the filetype, then a refresh runs on a buffer where `languages.hasProvider(SemanticTokens, uri)` is false or `languages.getLegend(...)` returned undefined — no server attached, server without semanticTokens capability, or server registered the capability without a legend.","commonSituations":"Language server version without semanticTokens support (pre-LSP 3.16); capability registered but legend negotiation failed; buffer detached from its client (server exited) while highlights refresh.","solutions":["Upgrade the language server to one supporting semanticTokens with a proper legend.","Verify capability with `:CocCommand document.checkBuffer` and check `:CocInfo` for client attachment.","Run `:CocRestart` if the server exited and the buffer is orphaned.","Remove the filetype from `semanticTokens.filetypes` if the server will never support it, to silence refresh attempts."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// only refresh when a semanticTokens provider is attached for this uri\nconst caps = await coc.commands.executeCommand('document.checkBuffer')\nif (!caps?.capabilities?.semanticTokensProvider) return","typeGuard":null,"tryCatchPattern":"try {\n  await buffer.checkState()\n} catch (e) {\n  if (String(e?.message).includes('SemanticTokens provider not found')) return\n  throw e\n}","preventionTips":["Use language servers supporting LSP >= 3.16 semantic tokens","Check client attachment after long sessions; run :CocRestart when orphaned","Only enable semanticTokens.filetypes for servers known to provide the capability and legend"],"tags":["lsp","semantic-tokens","missing-capability","coc-nvim"],"backgroundTag":"lsp-server-capability-not-supported","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}