coc-prettier
raw JSON → 11.0.1 verified Sat Apr 25 auth: no javascript
Prettier formatter extension for coc.nvim, version 11.0.1. Fork of prettier-vscode adapted for Neovim/Vim via the coc.nvim async completion framework. Supports formatting for JavaScript, TypeScript, CSS, HTML, Markdown, YAML, and more via Prettier plugins. Uses project-local or global Prettier installation with fallback to bundled version. Configure via coc-settings.json or Prettier config files. Release cadence follows coc.nvim ecosystem. Key differentiator: native integration with coc.nvim's async formatting pipeline vs standalone formatters.
Common errors
error CocInstall error: invalid extension ↓
cause The coc.nvim version is older than 0.0.82 or the extension name is misspelled.
fix
Update coc.nvim via
:CocUpdate and install with :CocInstall coc-prettier (note hyphen). error Prettier module not found ↓
cause Prettier is not installed locally nor globally, and the bundled version is missing or corrupted.
fix
Run
npm install prettier -D --save-exact in your project root. error Cannot read property 'format' of undefined ↓
cause Format action called but no formatter registered for the current filetype.
fix
Ensure prettier supports the filetype, or add a Prettier config. Check
:CocInfo to see registered formatters. Warnings
gotcha Local prettier installation overrides bundled version; ensure prettier is listed in project's devDependencies or root package.json to avoid version mismatch. ↓
fix Run `npm install prettier -D --save-exact` inside your project and verify it is resolved correctly.
gotcha Format-on-save requires explicit configuration in coc-settings.json; the extension does not enable it by default. ↓
fix Add `"coc.preferences.formatOnSaveFiletypes": [...]` to your coc-settings.json.
gotcha Plugins for additional languages (e.g., Ruby, PHP) must be installed separately and registered in package.json; this extension only activates plugins from a local or global prettier resolution. ↓
fix Install the desired plugin (e.g., `@prettier/plugin-ruby`) and ensure it appears in your project's package.json.
gotcha The `prettier.resolveGlobalModules` option (default false) if set to true may load global prettier which could mismatch project config or be untrusted; user will be prompted to confirm. ↓
fix Set `"prettier.resolveGlobalModules": false` (default) and always use local prettier.
gotcha Settings defined in coc-settings.json apply only when formatting via the extension, not via CLI; always use Prettier config files for consistent behavior across tools. ↓
fix Create .prettierrc in your project root and avoid relying on coc-settings.json for non-project files.
Install
npm install coc-prettier yarn add coc-prettier pnpm add coc-prettier Quickstart
:CocInstall coc-prettier
" In your project, after prettier is installed locally:
" format current buffer
:call CocAction('format')
" or use a key mapping
nmap <silent> <Leader>f <Plug>(coc-format)
" Automatically format on save via coc-settings.json:
" {
" "coc.preferences.formatOnSaveFiletypes": ["javascript", "typescript", "json", "html", "css", "markdown"]
" }