Catalog npm
Back to packageRELEASE DETAILS

1.2.0

npm

@0x706b/coc-prettier

prettier extension for coc.nvim

coc.nvimprettier
Published20 Oct 2021
Direct dependencies16
Transitive dependenciesNot calculated

README

Current package documentation

Prettier formatter for coc.nvim

Coc extension to format your JavaScript / TypeScript / CSS / JSON using Prettier.

A fork of prettier-vscode

Installation

Run vim command:

:CocInstall coc-prettier

Usage

Setup Prettier command in your init.vim or .vimrc

command! -nargs=0 Prettier :CocCommand prettier.formatFile

Then you can use :Prettier to format current buffer.

Remap keys for range format in your init.vim or .vimrc

vmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)

Then you can <leader>f for range format.

Prettier range format only support languageId including: javascript, javascriptreact, typescript, typescriptreact, json and graphql.

Update your coc-settings.json for format on save.

Open settings file with:

:CocConfig

Add:

  "coc.preferences.formatOnSaveFiletypes": ["css", "markdown"],

to setup the languages which you want to format on save.

Note: prettier extension have lower priority, if the document have other registered document format provider, prettier would not work.

To check the format is done by prettier, check out the output message after format, which should contains Formatted by prettier.

To make prettier do the format, use command :CocCommand prettier.formatFile

To save without formatting, use :noa w

Settings

Prettier's Settings

Settings will be read from (listed by priority):

  1. Prettier configuration file
  2. .editorconfig

Or if no prettier configuration file exist

  1. .editorconfig
  2. Coc prettier's settings (described below with their default)

prettier.printWidth (default: 80)

Fit code within this line limit

prettier.tabWidth (default: 2)

Number of spaces it should use per tab

prettier.singleQuote (default: false)

If true, will use single instead of double quotes

prettier.trailingComma (default: 'none')

Controls the printing of trailing commas wherever possible. Valid options:

  • "none" - No trailing commas
  • "es5" - Trailing commas where valid in ES5 (objects, arrays, etc)
  • "all" - Trailing commas wherever possible (function arguments)

prettier.bracketSpacing (default: true)

Controls the printing of spaces inside object literals

prettier.jsxBracketSameLine (default: false)

If true, puts the > of a multi-line jsx element at the end of the last line instead of being alone on the next line

prettier.parser (default: 'babylon') - JavaScript only

Which parser to use. Valid options are 'flow' and 'babylon'.

prettier.semi (default: true)

Whether to add a semicolon at the end of every line (semi: true), or only at the beginning of lines that may introduce ASI failures (semi: false)

prettier.useTabs (default: false)

If true, indent lines with tabs

prettier.proseWrap (default: 'preserve')

(Markdown) wrap prose over multiple lines.

prettier.arrowParens (default: 'avoid')

Include parentheses around a sole arrow function parameter

Coc specific settings

These settings are specific to Coc and need to be set in the Coc settings file. See the documentation for how to do that.

prettier.formatterPriority (default: 1) - priority of formatter

Change it to -1 if you don't want prettier to have higher priority than formatter provided by other language server.

prettier.eslintIntegration (default: false) - JavaScript and TypeScript only

Use prettier-eslint instead of prettier. Other settings will only be fallbacks in case they could not be inferred from ESLint rules.

prettier.tslintIntegration (default: false) - JavaScript and TypeScript only

Use prettier-tslint instead of prettier. Other settings will only be fallbacks in case they could not be inferred from TSLint rules.

prettier.stylelintIntegration (default: false) - CSS, SCSS and LESS only

Use prettier-stylelint instead of prettier. Other settings will only be fallbacks in case they could not be inferred from stylelint rules.

prettier.requireConfig (default: false)

Require a 'prettierconfig' to format

prettier.ignorePath (default: .prettierignore)

Supply the path to an ignore file such as .gitignore or .prettierignore. Files which match will not be formatted. Set to null to not read ignore files. Restart required.

prettier.disableLanguages (default: ["vue"])

A list of languages IDs to disable this extension on. Restart required. Note: Disabling a language enabled in a parent folder will prevent formatting instead of letting any other formatter to run

prettier.statusItemText (default: "Prettier")

Text of status item indicating current buffer can be formatted by prettier.

prettier.onlyUseLocalVersion (default: false)

Only use the version of prettier installed by the client, ignoring the version bundled with coc-prettier

prettier.disableSuccessMessage (default: false)

Disable the 'Formatted by prettier' message which is echoed every time a file is successfully formatted

Prettier resolution

This extension will use prettier from your project's local dependencies. Should prettier not be installed locally with your project's dependencies, a copy will be bundled with the extension.

ESLint and TSLint Integration

prettier-eslint and prettier-tslint are included with the installation of this extension. There is no need for a separate local or global install of either for functionality.

eslint, tslint, and all peer dependencies required by your specific configuration must be installed locally. Global installations will not be recognized.

Contribute

Feel free to open issues or PRs!

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 16

Native requirements
16 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@0x706b/prettier-eslint-8
Environment
{
  "local_name": "@0x706b/prettier-eslint-8",
  "alias": false,
  "peer_metadata": null
}
^0.0.2runtime
core-js
Environment
{
  "local_name": "core-js",
  "alias": false,
  "peer_metadata": null
}
^3.9.1runtime
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^2.2.1runtime
prettier-eslint
Environment
{
  "local_name": "prettier-eslint",
  "alias": false,
  "peer_metadata": null
}
^12.0.0runtime
prettier-stylelint
Environment
{
  "local_name": "prettier-stylelint",
  "alias": false,
  "peer_metadata": null
}
^0.4.2runtime
prettier-tslint
Environment
{
  "local_name": "prettier-tslint",
  "alias": false,
  "peer_metadata": null
}
^0.4.2runtime
@chemzqm/tsconfig
Environment
{
  "local_name": "@chemzqm/tsconfig",
  "alias": false,
  "peer_metadata": null
}
^0.0.3development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^14.14.31development
@types/semver
Environment
{
  "local_name": "@types/semver",
  "alias": false,
  "peer_metadata": null
}
^7.3.4development
coc.nvim
Environment
{
  "local_name": "coc.nvim",
  "alias": false,
  "peer_metadata": null
}
^0.0.80development
esbuild
Environment
{
  "local_name": "esbuild",
  "alias": false,
  "peer_metadata": null
}
^0.8.54development
ignore
Environment
{
  "local_name": "ignore",
  "alias": false,
  "peer_metadata": null
}
^5.1.8development
resolve-from
Environment
{
  "local_name": "resolve-from",
  "alias": false,
  "peer_metadata": null
}
^5.0.0development
rimraf
Environment
{
  "local_name": "rimraf",
  "alias": false,
  "peer_metadata": null
}
^3.0.2development
semver
Environment
{
  "local_name": "semver",
  "alias": false,
  "peer_metadata": null
}
^7.3.4development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^4.2.2development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "41b8b0eae1b36ec847d8497b9725f32a4d63c695",
  "integrity": "sha512-54BsIdGlWt+ZDc+jeiWpQQZHE8AvRuN36VGc0UChN9jj1RlLL5Z0JfuwFp2v95kWErQ8tceYxocGoi4KwHPw2Q==",
  "tarball": "https://registry.npmjs.org/@0x706b/coc-prettier/-/coc-prettier-1.2.0.tgz",
  "fileCount": 9,
  "unpackedSize": 109657,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIEXYJ9Tv1EHKVbfW1Td+yLqcBO7Ylw7FGNfg7lSaVEcVAiEAueTC1NRessB9lIuORrP8FFEtjLzdxvYXts8BNv/uSmE="
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:38 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:5df8cc78d7dec0aea92db808f15328816da2e4184e8307b2db10a3d12df60c73

Other collected versions

1.2.225 Dec1.2.121 OctView all collected versions →