Closed jaymakes11 closed 4 years ago
I'm working daily with my own plugin and it works fine in VS Code 🤔
So the problem must be something on your side 😟
node_modules
+ reload vscodenode_modules
is on relative root and not a subdirectory in the opened working diryarn prettier --write .
If you found any working solution, please let me and the community know with an answer 🙂
Thanks @Shinigami92. Glad to hear there's hope 🙂
When you have a Pug file open, do you see the Prettier indicator (button) in the bottom right status bar?
To answer your questions (which are super useful in helping debug this on my end, thank you!):
Have you tried a repo with clean installation of
node_modules
+ reload vscode
No, not yet. Will do so if need be.
Also
node_modules
is on relative root and not a subdirectory in the opened working dir
This could be the issue. I'm using PNPM for this particular project in a mono-repo fashion, but the relevant prettier and prettier-pug packages are in the root. Though, since it's working via the CLI i'm not sure this is the issue.
And did you check some extensions and disabled some of them
Yes, but I could dig more on this front.
Is CLI working? yarn prettier --write .
Yes (npx prettier --write index.pug
).
Did you backup and reset your VS Code settings?
No, this is a good idea though. Will do if need be.
How about explicitly specifying a defaultFormatter
for Pug/Jade, @Shinigami92?
i.e. Do you have anything like this in your JSON config?
"[jade]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[pug]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@yet-another-dev Any news?
If you solved it, please write a response and then close this issue :slightly_smiling_face:
After reinstalling my VS Code and ensuring no plugins other than the VS Prettier plugin was running I got it to work 😄
I did notice that that seeing jade
listed in the output for Prettier was required to get it to work:
Now to reenable extensions one-by-one to see which one was the culprit... If I find one I'll be sure to note it here but for now will close this issue. Thanks again for the tips and help with this, @Shinigami92.
Alright, after some more testing it seems that this is connected to pnpm. I'm using pnpm specifically for its monorepo features (which are pretty sweet!), so it's rather unfortunate that there's a conflict. If running npm i
and reloading VS Code then prettier is identified as the formatter for pug files. If running pnpm i
they are not.
I found a perhaps-related issue on the prettier-vscode plugin's repo.
Maybe related to https://github.com/prettier/prettier/pull/9167
Info
The issue
I can't seem to get this to work in VS Code (manually and on-save). When attempting to do so, VS Code shows "There is no formatter for 'jade' files installed." So it seems the issue is VS Code not having a formatter specified for Pug/Jade files... so, in my user/workspace settings I added:
But this still does not work.
Any ideas?