neoclide/coc.nvim · error · Error
Inlay hint provider not found for current document
Error message
Inlay hint provider not found for current document
What it means
coc.nvim throws this when an inlay hint operation (enable/disable/toggle) is requested for a buffer whose language server does not register an InlayHint provider. The handler checks `languages.hasProvider(ProviderName.InlayHint, ...)` before touching virtual text. It is a capability check, not an internal fault.
Source
Thrown at src/handler/inlayHint/buffer.ts:171
if (Array.isArray(filetypes)) return filetypes.includes('*') || filetypes.includes(this.doc.filetype)
return enable === true
}
public enable() {
this.checkState()
this.config.display = true
this.render(undefined, 0).catch(onUnexpectedError)
}
public disable() {
this.checkState()
this.config.display = false
this.clearCache()
this.clearVirtualText()
}
private checkState(): void {
if (!languages.hasProvider(ProviderName.InlayHint, this.doc.textDocument)) throw new Error('Inlay hint provider not found for current document')
if (!this.configEnabled) throw new Error(`Filetype "${this.doc.filetype}" not enabled by inlayHint configuration, see ':h coc-config-inlayHint'`)
}
public toggle(): void {
if (this.config.display) {
this.disable()
} else {
this.enable()
}
}
public clearCache(): void {
this.cancel()
this.currentHints = []
this.regions.clear()
}
public onTextChange(): void {View on GitHub (pinned to 50e974d969)
Solutions
- Install or upgrade a language server for the filetype that supports LSP inlayHintProvider (e.g. rust-analyzer, typescript-language-server >= 4).
- Verify the server is actually running for the buffer with `:CocCommand workspace.showOutput`.
- Check `:CocInfo` / `:CocCommand document.checkBuffer` that a client is attached and which capabilities it registered.
- Only toggle inlay hints in buffers with a capable server; gate keybindings by filetype if needed.
Example fix
// before: global keybind always toggles
vim.api.nvim_set_keymap('n', '<leader>ih', ':CocCommand document.toggleInlayHints<CR>', {})
// after: guard by capable filetype
local capable = { rust = true, typescript = true }
vim.keymap.set('n', '<leader>ih', function()
if capable[vim.bo.filetype] then vim.cmd('CocCommand document.toggleInlayHints') end
end, {}) Defensive patterns
Strategy: validation
Validate before calling
// bail out before toggling when no inlayHint provider exists
const hasInlayHints = await coc.services.has('inlayHintProvider') // or track via CocAttachUpdate
if (!hasInlayHints) return Try / catch
try {
await coc.commands.executeCommand('document.toggleInlayHints')
} catch (e) {
if (String(e?.message).includes('Inlay hint provider not found')) return vim.notify('No language server with inlay hints')
throw e
} Prevention
- Check `:CocCommand document.checkBuffer` before binding inlay-hint toggles
- Keep language servers updated to LSP >= 3.17 for inlayHintProvider
- Scope the toggle keybinding to filetypes with known inlay-hint support
When it happens
Trigger: Calling `:CocCommand document.toggleInlayHints` (enable/disable/toggle) on a document whose LSP server has not declared the `inlayHintProvider` capability, or when no language server is attached at all.
Common situations: Editing a filetype with no running LSP (e.g. plain text); an older language server that predates the LSP 3.17 inlayHint feature; a server that supports other features (completion, hover) but not inlay hints.
Related errors
- Filetype "${this.doc.filetype}" not enabled by inlayHint con
- Rename provider not found for current buffer
- SemanticTokens provider not found for ${this.doc.uri}
- Failed to resolve link target
- Provider returns null on prepare, unable to rename at curren
AI-assisted analysis of neoclide/coc.nvim@50e974d969 (2026-08-31).
Data as JSON: /api/errors/21345e03f6c864f3.
Report an issue: GitHub.