{"id":13479408,"url":"https://github.com/neoclide/coc-prettier","last_synced_at":"2025-05-14T15:07:06.758Z","repository":{"id":38029586,"uuid":"148209320","full_name":"neoclide/coc-prettier","owner":"neoclide","description":"Prettier extension for coc.nvim.","archived":false,"fork":false,"pushed_at":"2025-03-03T08:58:40.000Z","size":553,"stargazers_count":554,"open_issues_count":19,"forks_count":46,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-03T21:02:23.406Z","etag":null,"topics":["coc","neovim","prettier","vim"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neoclide.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-10T19:40:24.000Z","updated_at":"2025-04-14T13:30:49.000Z","dependencies_parsed_at":"2024-06-18T21:34:19.410Z","dependency_job_id":"295e4a87-d434-4057-b110-ca2c72778b91","html_url":"https://github.com/neoclide/coc-prettier","commit_stats":{"total_commits":125,"total_committers":29,"mean_commits":4.310344827586207,"dds":"0.30400000000000005","last_synced_commit":"b0f67a8685cf71b3d1acb6c78da148fc8caa960f"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-prettier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-prettier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-prettier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neoclide%2Fcoc-prettier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neoclide","download_url":"https://codeload.github.com/neoclide/coc-prettier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254169454,"owners_count":22026212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coc","neovim","prettier","vim"],"created_at":"2024-07-31T16:02:15.430Z","updated_at":"2025-05-14T15:07:06.723Z","avatar_url":"https://github.com/neoclide.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Formatter"],"sub_categories":[],"readme":"# Prettier formatter for coc.nvim\n\nFork of [prettier-vscode](https://github.com/prettier/prettier-vscode) to work\nwith [coc.nvim](https://github.com/neoclide/coc.nvim)\n\n[Prettier](https://prettier.io/) is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.\n\n\u003cp align=\"center\"\u003e\n  \u003cem\u003e\n    JavaScript\n    · TypeScript\n    · Flow\n    · JSX\n    · JSON\n  \u003c/em\u003e\n  \u003cbr /\u003e\n  \u003cem\u003e\n    CSS\n    · SCSS\n    · Less\n  \u003c/em\u003e\n  \u003cbr /\u003e\n  \u003cem\u003e\n    HTML\n    · Vue\n    · Angular\n  \u003c/em\u003e\n  \u003cem\u003e\n    HANDLEBARS\n    · Ember\n    · Glimmer\n  \u003c/em\u003e\n  \u003cbr /\u003e\n  \u003cem\u003e\n    GraphQL\n    · Markdown\n    · YAML\n  \u003c/em\u003e\n  \u003cbr /\u003e\n  \u003cem\u003e\n    \u003ca href=\"https://prettier.io/docs/en/plugins.html\"\u003e\n      Your favorite language?\n    \u003c/a\u003e\n  \u003c/em\u003e\n\u003c/p\u003e\n\n## Installation\n\nRun vim command:\n\n```\n:CocInstall coc-prettier\n```\n\n## Debug log\n\n- Add `\"prettier.enableDebugLogs\": true` to coc-settings.json opened by `: CocConfig`.\n- Checkout output by `:CocCommand prettier.openOutput`.\n\n## New feature of 11.0.0\n\n- Added configuration properties: `prettier.singleAttributePerLine`, `prettier.jsxBracketSameLine` and `prettier.experimentalTernaries`.\n\n### Prettier Resolution\n\nThis extension will use prettier from your project's local dependencies (recommended). When the `prettier.resolveGlobalModules` is set to `true` the extension can also attempt to resolve global modules. Should prettier not be installed locally with your project's dependencies or globally on the machine, the version of prettier that is bundled with the extension will be used.\n\nTo install prettier in your project and pin its version [as recommended](https://prettier.io/docs/en/install.html), run:\n\n```\nnpm install prettier -D --save-exact\n```\n\n\u003e NOTE: You will be prompted to confirm that you want the extension to load a Prettier module. This is done to ensure that you are not loading a module or script that is not trusted.\n\n### Plugins\n\nThis extension supports [Prettier plugins](https://prettier.io/docs/en/plugins.html) when you are using a locally or globally resolved version of prettier. If you have Prettier and a plugin registered in your `package.json`, this extension will attempt to register the language and provide automatic code formatting for the built-in and plugin languages.\n\n## Configuration\n\nThere are multiple options for configuring Prettier with this extension. You can use coc.nvim's configuration file `.vim/coc-settings.json`, [prettier configuration files](https://prettier.io/docs/en/configuration.html), or an `.editorconfig` file. The coc.nvim settings are meant to be used as a fallback and are generally intended only for use on non-project files. **It is recommended that you always include a prettier configuration file in your project specifying all settings for your project.** This will ensure that no matter how you run prettier - from this extension, from the CLI, or from another IDE with Prettier, the same settings will get applied.\n\nUsing [Prettier Configuration files](https://prettier.io/docs/en/configuration.html) to set formatting options is the recommended approach. Options are searched recursively down from the file being formatted so if you want to apply prettier settings to your entire project simply set a configuration in the root. Settings can also be configured through coc-settings.json - however, these settings will only apply while running the extension, not when running prettier through the command line.\n\n### Configuring Default Options\n\nSome users may not wish to create a new Prettier config for every project or use the coc-settings.json. In order to set a default configuration, set [`prettier.configPath`](https://github.com/prettier/prettier-vscode#prettierconfigpath). However, be careful, if this is set this value will always be used and local configuration files will be ignored.\n\n### Coc.nvim Settings\n\nYou can use [coc.nvim settings](#prettier-settings) to configure prettier. Settings will be read from (listed by priority):\n\n1. [Prettier configuration file](https://prettier.io/docs/en/configuration.html)\n1. `.editorconfig`\n1. Configuration of coc.nvim (Ignored if any other configuration is present)\n\n\u003e NOTE: If any local configuration file is present (i.e. `.prettierrc`) the coc.nvim settings will **NOT** be used.\n\n## Usage\n\n### Create custom vim command\n\nSetup `Prettier` command in your `init.vim` or `.vimrc`\n\n```\ncommand! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument\n```\n\nThen you can use `:Prettier` to format the current buffer by coc-prettier.\n\nOr use `:CocCommand` to open command list.\n\n### Range format\n\nRemap keys for range format in your `init.vim` or `.vimrc`\n\n```\nvmap \u003cleader\u003ef  \u003cPlug\u003e(coc-format-selected)\nnmap \u003cleader\u003ef  \u003cPlug\u003e(coc-format-selected)\n```\n\nThen you can `\u003cleader\u003ef` for range format.\n\nFormat selection works on several languages depending on what Prettier itself supports. The following languages currently are supported:\n\n```\njavascript\njavascriptreact\ntypescript\ntypescriptreact\njson\ngraphql\nhandlebars\n```\n\n### Format On Save.\n\nOpen settings file with:\n\n    :CocConfig\n\nAdd:\n\n```\n  \"coc.preferences.formatOnSaveFiletypes\": [\"css\", \"markdown\"],\n```\n\nto setup the languages which you want to format on save.\n\n**Note:** if prettier extension have lower priority, and document have other\nregistered document format provider, prettier will be ignored.\n\nTo disable coc-prettier for specific files, you can create `.prettierignore`\nfile. Or use `\"prettier.disableLanguages\"` configuration, or\n`\"prettier.formatterPriority\": -1` configuration to make it not override format\nprovider from other coc.nvim extensions.\n\nTo check the format is done by prettier, check out the output message after\nformat, which should contains `Formatted by prettier`.\n\nOther useful commands:\n\n- `:CocCommand prettier.formatFile`: force prettier to format the current\n  buffer, even if another format provider exists.\n- `:noa w`: save the current buffer _without_ formatting.\n- `:CocCommand prettier.createConfigFile`: Create `.prettierrc` for current\n  document.\n\n### Format Document (Forced)\n\nIf you would like to format a document that is configured to be ignored by Prettier either because it is in a `.prettierignore` file or part of a normally excluded location like `node_modules`, you can run the command **Format Document (Forced)** to force the document to be formatted. Forced mode will also ignore any config for `requirePragma` allowing you to format files without the pragma comment present.\n\n## Linter Integration\n\nThe recommended way of integrating with linters is to let Prettier do the formatting and configure the linter to not deal with formatting rules. You can find instructions on how to configure each linter on the Prettier docs site. You can then use each of the linting extensions as you normally would. For details refer to the [Prettier documentation](https://prettier.io/docs/en/integrating-with-linters.html).\n\n## Settings\n\n### Prettier Settings\n\nAll prettier options can be configured directly in this extension. These settings are used as a fallback when no configuration file is present in your project, see the [configuration](#configuration) section of this document for more details. For reference on the options see the [prettier documentation](https://prettier.io/docs/en/options.html).\n\n\u003e The default values of these configurations are always to their Prettier 2.0 defaults. In order to use defaults from earlier versions of prettier you must set them manually using your coc-prettier settings or local project configurations.\n\n```\nprettier.arrowParens\nprettier.bracketSpacing\nprettier.endOfLine\nprettier.htmlWhitespaceSensitivity\nprettier.insertPragma\nprettier.bracketSameLine\nprettier.jsxSingleQuote\nprettier.printWidth\nprettier.proseWrap\nprettier.quoteProps\nprettier.requirePragma\nprettier.semi\nprettier.singleQuote\nprettier.tabWidth\nprettier.trailingComma\nprettier.useTabs\nprettier.vueIndentScriptAndStyle\nprettier.embeddedLanguageFormatting\n```\n\n### Extension Settings\n\nThese settings are specific to coc-prettier and need to be set in coc-settings.json. See the [documentation](https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file) for how to do that.\n\n#### prettier.enable (default: `true`)\n\nControls whether prettier is enabled or not. You must restart coc.nvim when you change this setting.\n\n#### prettier.disableLanguages (default: [\"vue\"])\n\nA list of languages IDs to disable this extension on. Restart required.\n_Note: Disabling a language enabled in a parent folder will prevent formatting instead of letting any other formatter to run_\n\nYou must restart coc.nvim when you change this setting.\n\n#### prettier.formatterPriority (default: 1) - priority of formatter\n\nChange it to `-1` if you don't want prettier to have higher priority than\nformatter provided by other language server.\n\n#### prettier.statusItemText (default: \"Prettier\")\n\nText of status item indicating current buffer can be formatted by prettier.\n\n#### prettier.requireConfig (default: `false`)\n\nRequire a prettier configuration file to format files. Untitled files will still be formatted using the coc-prettier Prettier configuration even with this option set to `true`.\n\n#### prettier.ignorePath (default: `.prettierignore`)\n\nSupply the path to an ignore file such as `.gitignore` or `.prettierignore`.\nFiles which match will not be formatted. Set to `null` to not read ignore files.\n\n**Note, if this is set, this value will always be used and local ignore files will be ignored.**\n\n**Disabled on untrusted workspaces**\n\n#### prettier.configPath\n\nSupply a custom path to the prettier configuration file.\n\n**Note, if this is set, this value will always be used and local configuration files will be ignored. A better option for global defaults is to put a `~/.prettierrc` file in your home directory.**\n\n**Disabled on untrusted workspaces**\n\n#### prettier.prettierPath\n\nSupply a custom path to the prettier module. This path should be to the module folder, not the bin/script path. i.e. `./node_modules/prettier`, not `./bin/prettier`.\n\n**Disabled on untrusted workspaces**\n\n#### prettier.resolveGlobalModules (default: `false`)\n\nWhen enabled, this extension will attempt to use global npm or yarn modules if local modules cannot be resolved.\n\n\u003e NOTE: This setting can have a negative performance impact, particularly on Windows when you have attached network drives. Only enable this if you must use global modules. It is recommended that you always use local modules when possible.\n\n**Note: Disabling a language enabled in a parent folder will prevent formatting instead of letting any other formatter to run**\n\n**Disabled on untrusted workspaces**\n\n#### prettier.documentSelectors\n\nA list of [glob patterns](https://code.visualstudio.com/api/references/vscode-api#GlobPattern) to register Prettier formatter. Typically these will be in the format of `**/*.abc` to tell this extension to register itself as the formatter for all files with the `abc` extension. This feature can be useful when you have [overrides](https://prettier.io/docs/en/configuration.html#configuration-overrides) set in your config file to map custom extensions to a parser.\n\nIt is likely will need to also update your prettier config. For example, if I register the following document selector by itself, Prettier still won't know what to do with that file. I either need a Prettier extension that formats `.abc` file format or I need to configure Prettier.\n\n```json\n{\n  \"prettier.documentSelectors\": [\"**/*.abc\"]\n}\n```\n\nTo tell Prettier how to format a file of type `.abc` I can set an override in the prettier config that makes this file type use the `babel` parser.\n\n```json\n{\n  \"overrides\": [\n    {\n      \"files\": \"*.abc\",\n      \"options\": {\n        \"parser\": \"babel\"\n      }\n    }\n  ]\n}\n```\n\n**Disabled on untrusted workspaces**\n\n#### prettier.useEditorConfig (default: `true`)\n\nWhether or not to take .editorconfig into account when parsing configuration. See the [prettier.resolveConfig docs](https://prettier.io/docs/en/api.html) for details.\n\n**Disabled on untrusted workspaces (always false)**\n\n#### prettier.withNodeModules (default: `false`)\n\nWhether or not to process files in the `node_modules` folder.\n\n**Disabled on untrusted workspaces**\n\n## Error Messages\n\n**Failed to load module. If you have prettier or plugins referenced in package.json, ensure you have run `npm install`**\n\nWhen a `package.json` is present in your project and it contains prettier, plugins, or linter libraries this extension will attempt to load these modules from your `node_module` folder. If you see this error, it most likely means you need to run `npm install` or `yarn install` to install the packages in your `package.json`.\n\n**Your project is configured to use an outdated version of prettier that cannot be used by this extension. Upgrade to the latest version of prettier.**\n\nYou have to upgrade to a newer version of prettier.\n\n## Contribute\n\nFeel free to open issues or PRs!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneoclide%2Fcoc-prettier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneoclide%2Fcoc-prettier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneoclide%2Fcoc-prettier/lists"}