Closed maricn closed 2 years ago
I'm running into the same issue, except it only happens on a specific file. Other files get properly formatted.
I'm running into the same issue, except it only happens on a specific file. Other files get properly formatted.
Same here, with an html file
Just out of curiosity, as I had a similar problem. Does add prettier-tslint
to your project solve the issue?
Just out of curiosity, as I had a similar problem. Does add
prettier-tslint
to your project solve the issue?
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.
It could be using bundled prettier from coc-prettier before.
@maricn This is what puzzles me also, as the bundled prettier-tslint is in there (in coc-prettier's node modules/.bin)
Local prettier is used when possible by default, so when you don't have local prettier, global prettier is used.
@chemzqm I think that this is not the same functionality as vs code. In vs code I didn't have to install prettier-tslint in order to make it work with typescript files. Maybe this is a bug?
I see, seems API used by prettier get changed.
Works as expected for me, don't know how to reproduce.
@chemzqm Without going into the internals of this package, maybe this line from my original post is helpful:
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.
So, maybe the way the plugin detects failure of the external command is flawed? It reports success, but actually nothing happened. Is the fallback to plugin's prettier working in case there's an error with the local one (if it's how it works anyways)?
Please checkout output from coc-prettier https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel
Please checkout output from coc-prettier neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel
This is what happens without prettier-tslint
when I do :call CocAction('format')
:
[Error - 6/18/2021, 6:07:32 PM:] Failed to load prettier-tslint from /home/nikola/.dotfiles/.config/coc/extensions/node_modules/coc-prettier
[Error - 6/18/2021, 6:07:32 PM:] Cannot read property 'format' of null
[Trace - 6/18/2021, 6:07:32 PM:] Formatted file: file:///home/nikola/Workspace/ProjectXXX/src/PackageYYY/FileZZZ.ts
[Trace - 6/18/2021, 6:07:32 PM:] Prettier format edits: [
{
"range": {
"start": {
"character": 0,
"line": 0
},
"end": {
"character": 0,
"line": 54
}
},
"newText": "REDACTED"
}
]
there's some symlinks on that path, but this is what's there:
$> ls -lah /home/nikola/.dotfiles/.config/coc/extensions/node_modules/coc-prettier
.rw-r--r-- nikola nikola 116 B Tue Mar 30 10:30:48 2021 .prettierrc
drwxr-xr-x nikola nikola 4.0 KB Tue Mar 30 10:30:48 2021 .release/
.rw-r--r-- nikola nikola 460 B Tue Mar 30 10:30:48 2021 CHANGELOG.md
.rw-r--r-- nikola nikola 481 B Tue Mar 30 10:30:48 2021 esbuild.js
drwxr-xr-x nikola nikola 4.0 KB Tue Mar 30 10:30:48 2021 lib/
drwxr-xr-x nikola nikola 20 KB Tue Mar 30 10:30:48 2021 node_modules/
.rw-r--r-- nikola nikola 233 B Tue Mar 30 10:30:34 2021 package-json-schema.json
.rw-r--r-- nikola nikola 204 KB Tue Mar 30 10:30:34 2021 package-lock.json
.rw-r--r-- nikola nikola 7.7 KB Tue Mar 30 10:30:34 2021 package.json
.rw-r--r-- nikola nikola 5.9 KB Tue Mar 30 10:30:48 2021 Readme.md
And the list of extensions in nvim sees coc-prettier
version 1.1.23
atm at that path.
Not sure what this line means:
[Error - 6/18/2021, 6:07:32 PM:] Cannot read property 'format' of null
There should be prettier-tslint inside node_modules folder of coc-prettier
There should be prettier-tslint inside node_modules folder of coc-prettier
I have prettier-tslint
version 0.4.2
(latest, from Jan 2019) inside coc-prettier
version 1.1.23
.
I'm using coc-prettier@1.1.24
. I was having a similar problem where files were not being formatted and just a new line was being added to the end of the file. After installing prettier-tslint
to my project it started working again.
Make sure check the Prettier output by :CocCommand workspace.showOutput
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
v10.20.1
andv12.14.1
)prettier
dependency to the latest versionWhat works well
Which works just fine.
./node_modules/prettier/bin-prettier.js src/main.ts
from the project's root, the output is properly reformatted file.Context (files)
:CocConfig
(only global, no local):.config/coc/extensions/package.json
:.prettierrc
:tslint.json
: