coc-prettier: [help] Silent failure
What doesn’t work
:call CocAction('format')
:CocCommand prettier.formatFile
:Prettier
The commands report success, but the file doesn’t change. Especially with :call CocAction('format')
I get the response [coc.nvim] Formatted by prettier
, while with other two commands it just finishes without reporting anything in the output. Ofc, format on save doesn’t work.
All of those worked completely fine until a few days ago. I don’t know what changed, I did run arch packages update and update of vim plugins and of coc extensions but i’ve also tried reverting them without fixing the problem.
I tried
- reverting my dotfiles to a point where it surely worked (my .vimrc)
- reverting the project in question to a point when it worked
- trying it out on a different typescript project (the two use node versions
v10.20.1
andv12.14.1
) - reinstalling older version of coc-prettier (tried 1.1.18, 1.1.19, 1.1.20)
- updating
prettier
dependency to the latest version
What works well
- Interesting thing is that in that project I have this script:
"format": "prettier --write \"src/**/*.ts\""
Which works just fine.
- Also if I run
./node_modules/prettier/bin-prettier.js src/main.ts
from the project’s root, the output is properly reformatted file. - Running it on a pure javascript file works well (in any project)
Context (files)
:CocConfig
(only global, no local):
{
"prettier.tslintIntegration": true,
"coc.preferences.formatOnSaveFiletypes": [
"css",
"javascript",
"typescript",
"json",
"jsonc"
],
"coc.preferences.colorSupport": false,
"diagnostic.hintSign": ">>",
"diagnostic.infoSign": "ℹ️",
"diagnostic.warningSign": "⚠️",
"diagnostic.errorSign": "💣",
"diagnostic.enableHighlightLineNumber": true,
"diagnostic-languageserver.filetypes": {
"vim": "vint",
"email": "languagetool",
"markdown": ["write-good", "markdownlint"],
"sh": "shellcheck"
},
"typescript.preferences.importModuleSpecifier": "relative",
"markdownlint.config": {
"line-length": false,
"MD022": false,
"MD032": false,
"MD033": false, // inline HTML shouldn't be forbidden (<a name="asdf"></a>...[goto](#asdf))
"MD034": false,
"MD025": { "front_matter_title": "" }
},
"languageserver": {
"ccls": {
"command": "ccls",
"filetypes": ["c", "cpp", "cuda", "objc", "objcpp"],
"rootPatterns": [".ccls-root", "compile_commands.json"],
"initializationOptions": {
"cache": {
"directory": ".ccls-cache"
},
"client": {
"snippetSupport": true
}
}
}
},
"explorer.icon.enableNerdfont": true
}
.config/coc/extensions/package.json
:
{
"dependencies": {
"coc-db": ">=0.0.43",
"coc-emoji": ">=1.2.3",
"coc-explorer": ">=0.9.1",
"coc-highlight": ">=1.2.6",
"coc-jest": ">=1.1.1",
"coc-json": ">=1.3.2",
"coc-markdownlint": ">=1.7.0",
"coc-prettier": ">=1.1.18",
"coc-python": ">=1.2.13",
"coc-sql": ">=0.4.0",
"coc-syntax": ">=1.2.4",
"coc-tsserver": ">=1.6.0",
"coc-word": ">=1.2.2"
}
}
.prettierrc
:
{
"useTabs": false,
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"printWidth": 120
}
tslint.json
:
{
"defaultSeverity": "error",
"extends": ["tslint:recommended", "tslint-config-prettier"],
"jsRules": {
"no-unused-expression": true
},
"rules": {
"arrow-parens": false,
"array-type": false,
"curly": [true, "ignore-same-line"],
"eofline": true,
"indent": [true, "spaces", 2],
"interface-name": false,
"max-classes-per-file": false,
"max-line-length": [true, 120],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"public-static-field",
"public-static-method",
"protected-static-field",
"protected-static-method",
"private-static-field",
"private-static-method",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"public-constructor",
"protected-constructor",
"private-constructor",
"public-instance-method",
"protected-instance-method",
"private-instance-method"
]
}
],
"no-empty": false,
"no-empty-interface": false,
"no-unused-expression": true,
"object-literal-sort-keys": false,
"one-line": true,
"one-variable-per-declaration": true,
"ordered-imports": true,
"quotemark": [true, "single", "avoid-escape"],
"variable-name": [
true,
"ban-keywords",
"check-format",
"allow-snake-case",
"allow-pascal-case",
"allow-leading-underscore"
]
},
"rulesDirectory": []
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 17 (7 by maintainers)
Just out of curiosity, as I had a similar problem. Does add
prettier-tslint
to your project solve the issue?Make sure check the Prettier output by
:CocCommand workspace.showOutput
Finally! @kozer Yes, it does, the magic is back 🧙
But I’m still puzzled why this became necessary out of sudden when it was working before.