{"record":{"id":"8124427d45d5a919","repo":"neoclide/coc.nvim","slug":"format-provider-not-found-for-buffer-doc-bufnr","errorCode":null,"errorMessage":"Format provider not found for buffer: ${doc.bufnr}","messagePattern":"Format provider not found for buffer: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/handler/format.ts","lineNumber":111,"sourceCode":"    await doc.applyEdits(edits, false, true)\n    this.logProvider(doc.bufnr, edits)\n    return true\n  }\n\n  public async formatCurrentBuffer(): Promise<boolean> {\n    let { doc } = await this.handler.getCurrentState()\n    return await this.documentFormat(doc)\n  }\n\n  public async formatCurrentRange(mode: string): Promise<number> {\n    let { doc } = await this.handler.getCurrentState()\n    return await this.documentRangeFormat(doc, mode)\n  }\n\n  public async documentFormat(doc: Document): Promise<boolean> {\n    await doc.synchronize()\n    if (!languages.hasFormatProvider(doc.textDocument)) {\n      throw new Error(`Format provider not found for buffer: ${doc.bufnr}`)\n    }\n    let options = await workspace.getFormatOptions(doc.uri)\n    let textEdits = await this.handler.withRequestToken('format', token => {\n      return languages.provideDocumentFormattingEdits(doc.textDocument, options, token)\n    })\n    if (textEdits && textEdits.length > 0) {\n      await doc.applyEdits(textEdits, false, true)\n      this.logProvider(doc.bufnr, textEdits)\n      return true\n    }\n    return false\n  }\n\n  public async handleEnter(bufnr: number): Promise<void> {\n    let { nvim } = this\n    let { bracketEnterImprove } = this.preferences\n    let doc = workspace.getDocument(bufnr)\n    if (!doc || !doc.attached) return","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/handler/format.ts#L93-L129","documentation":"Thrown by documentFormat when no language server registered a document formatting provider for the given buffer. coc cannot format the buffer because no provider handles textDocument/formatting for it.","triggerScenarios":"Invoking format (:CocCommand or CocAction format) on a buffer whose filetype has no server with documentFormattingProvider capability, after doc.synchronize() confirms provider absence via languages.hasFormatProvider().","commonSituations":"Buffer filetype not covered by any installed language server; server running but without formatting capability; formatting extensions (prettier etc.) not installed/enabled for that filetype.","solutions":["Install/enable a formatter provider for the filetype (e.g. coc-prettier for js/ts/json)","Check the server's capabilities support documentFormattingProvider","Use rangeFormat or an external formatter if the server only supports range formatting"],"exampleFix":"// before\n:CocCommand format # buffer without provider\n// after\n:CocInstall coc-prettier  # or configure a server with formatting capability for the filetype","handlingStrategy":"try-catch","validationCode":"// pre-check via coc API surface used internally\nconst hasProvider = await nvim.call('coc#client#request', ['format']) // or gate on known formatter extensions installed for filetype","typeGuard":null,"tryCatchPattern":"try {\n  await formatCurrentBuffer();\n} catch (e) {\n  if (String(e.message).includes('Format provider not found')) {\n    console.warn('Install a formatter extension for this filetype (e.g. coc-prettier)');\n    return false;\n  }\n  throw e;\n}","preventionTips":["Install formatter extensions for filetypes you edit","Verify server formatting capability in :CocCommand workspace diagnostics","Gate format commands on known filetype support"],"tags":["formatting","lsp","provider-missing"],"backgroundTag":"format-provider-not-found","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}