coc-prettier: Prettier not being run when saving files
I have coc-prettier
installed and have setup coc-nvim as follows:
"coc.preferences.formatOnSaveFiletypes": [
"markdown",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"json",
"graphql",
"elixir",
"eelixir"
]
when I save a js
, jsx
, ts
, or tsx
file, coc-prettier
does nothing. For many months it was working as expected but suddenly has stopped.
Here is the output of CocInfo
:
## versions
vim version: NVIM v0.4.2
node version: v10.15.3
coc.nvim version: 0.0.74-bc017b02e6
term: iTerm.app
platform: darwin
## Messages
## Output channel: watchman
[Info - 10:48:04 AM] watchman watching project: /Users/thedelchop/Workspace/daydream
[Info - 10:48:04 AM] subscribing "**/.eslintr{c.js,c.yaml,c.yml,c,c.json}" in /Users/thedelchop/Workspace/daydream
[Info - 10:48:04 AM] subscribing "**/.eslintignore" in /Users/thedelchop/Workspace/daydream
[Info - 10:48:04 AM] subscribing "**/package.json" in /Users/thedelchop/Workspace/daydream
[Info - 10:48:04 AM] subscribing "**/{.prettierrc,.prettierrc.json,.prettierrc.yaml,.prettierrc.yml,.prettierrc.js,package.json,prettier.config.js}" in /Users/thedelchop/Workspace/daydream
[Info - 10:48:05 AM] subscribing "**/[tj]sconfig.json" in /Users/thedelchop/Workspace/daydream
[Info - 10:48:05 AM] subscribing "**/package.json" in /Users/thedelchop/Workspace/daydream
[Info - 10:48:05 AM] subscribing "**/*.{ts,tsx}" in /Users/thedelchop/Workspace/daydream
[Info - 10:48:05 AM] subscribing "**/*.{js,jsx}" in /Users/thedelchop/Workspace/daydream
## Output channel: prettier
## Output channel: git
Looking for git in: git
> git rev-parse --show-toplevel
resolved root: /Users/thedelchop/Workspace/daydream
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
resolved root: /Users/thedelchop/Workspace/daydream
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
resolved root: /Users/thedelchop/Workspace/daydream
> git ls-files -- assets/js/components/Authentication.tsx
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
> git --no-pager show :assets/js/components/Authentication.tsx
resolved root: /Users/thedelchop/Workspace/daydream
resolved root: /Users/thedelchop/Workspace/daydream
> git symbolic-ref --short HEAD
> git ls-files -- assets/js/components/Authentication.tsx
> git diff --name-status
> git diff --staged --name-status
> git ls-files --others --exclude-standard
> git --no-pager show :assets/js/components/Authentication.tsx
## Output channel: tsserver
[Info - 10:48:05 AM] Forking TSServer
PATH: /Users/thedelchop/.asdf/installs/nodejs/10.15.3/bin:/Users/thedelchop/.asdf/installs/nodejs/10.15.3/.npm/bin:/Users/thedelchop/.asdf/shims:/Users/thedelchop/.local/share/asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/thedelchop/.asdf/installs/ruby/2.6.3/bin:/Users/thedelchop/.SpaceVim/bin:/Users/thedelchop/.config/oh-my-zsh/plugins/desk:/Users/thedelchop/.config/oh-my-zsh/plugins/diff-so-fancy/bin:/Users/thedelchop/.config/oh-my-zsh/plugins/desk
[Info - 10:48:05 AM] Started TSServer
{
"path": "/Users/thedelchop/Workspace/daydream/node_modules/typescript/lib",
"_api": {
"versionString": "3.6.2",
"version": "3.6.2"
}
}
## Output channel: eslint
[Info - 10:48:05 AM] ESLint server running in node v10.15.3
[Info - 10:48:06 AM] ESLint library loaded from: /Users/thedelchop/Workspace/daydream/node_modules/eslint/lib/api.js
and the output of CocOpenLog
:
2019-11-18T10:48:04.153 INFO (pid:74765) [services] - registed service "eslint"
2019-11-18T10:48:04.366 INFO (pid:74765) [plugin] - coc 0.0.74-bc017b02e6 initialized with node: v10.15.3
2019-11-18T10:48:04.411 INFO (pid:74765) [watchman] - watchman watching project: /Users/thedelchop/Workspace/daydream
2019-11-18T10:48:05.461 INFO (pid:74765) [services] - eslint langserver state change: stopped => starting
2019-11-18T10:48:05.495 INFO (pid:74765) [services] - registed service "tsserver"
2019-11-18T10:48:05.522 INFO (pid:74765) [language-client-index] - eslint started with 74949
2019-11-18T10:48:05.606 INFO (pid:74765) [services] - service tsserver started
2019-11-18T10:48:05.637 INFO (pid:74765) [services] - eslint langserver state change: starting => running
2019-11-18T10:48:05.642 INFO (pid:74765) [services] - service eslint started
Can anyone point me in the right direction to figure out why its not working anymore?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (5 by maintainers)
It’s still not working. I am having a similar issue.
coc-prettier
is not working properly and is not formatting on save no matter what I try.I’m having the same issue as @masaeedu. I can only get
coc-prettier
to format on save if"coc.preferences.formatOnSaveFiletypes": ["*"]
.I found that if I change the setting to the following:
and restart Vim, I am able to get formatting on save.
I’ve tried various other configurations and none of them seem to work, not sure why:
If you’re still experiencing this problem: check out if your coc-settings.json file is formatted properly. { “coc.preferences.formatOnSaveFiletypes”: [ “markdown”, “javascript”, “javascriptreact”, “typescript”, “typescriptreact”, “json”, “graphql”, “elixir”, “eelixir”"] } works like a charm
Update coc.nvim
Can confirm that I am still seeing this. Can’t figure out why.
Checkout your
&filetype
.Nevermind, I figured out that this was because of a misconfigured global
.prettierrc
. Sorry about the false alarm.The
formatOnSave
feature nevertheless doesn’t work. It only works if I manually execute:CocCommand prettier.formatFile
.@chemzqm
set ft?
reports the filetype is json, which is as expected. I think this is just a bug in coc-prettier.