-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatting doesn't work in VScode #1730
Comments
Did you already try installing the plugin locally in your project? ( Also see #1721 (comment) for step-by-step instructions. |
Hi Czosel, Yes, I tried installing the plugin locally, but the same issue still exists.
|
Same problem. On terminal Prettier formats without problems, but VSCode's extension doesn't recognize the plugin. Even specifying the global or local node_modules in My local {
"phpVersion": "7.0",
"tabWidth": 4,
"useTabs": false,
"singleQuote": true,
"trailingCommaPHP": true,
"pluginSearchDirs": [
"/HDExterno/Langs/PHP/plugin/html/wp-content/themes/api/node_modules",
"./node_modules",
"node_modules"
],
"plugins": [
"@prettier/plugin-php"
],
"parser": "php"
} My {
// ...
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[php]": {
"editor.formatOnSave": true
},
// ...
} |
@D1360-64RC14 setting pluginSearchDirs, plugins and parser is not necessary if prettierrc is in the same path as your node_modules folder. |
I was also having trouble with the global installation. Adding this to my vscode user
|
@kjoedion makes sense. For me I install prettier php for every project individually |
The solutions I found across the various tickets here didn't work for me unfortunately, but appreciate everyones efforts to come up with a solution. I had to extend the prettier document selectors within VS Code to get it to run on PHP files: .vscode/settings.json
I also added
All works fine in VS Code for me now. Hopefully this helps someone else. Thanks for this plugin, big fan of prettier and so I'm really grateful I can bring some of that experience over to the small amount of PHP work I am doing. Related tickets are: #1721, #1640, prettier/prettier-vscode#2564 |
@WazzaJB thanks for the write-up! If this is reproducible in a fresh VScode installation, I'd be happy to add this to our documentation 👍 |
In that case I shall raise a PR and try to prepare a codespace you can trial this in :) |
Thanks a lot, @WazzaJB. Your solution works perfectly. Thanks for sharing. |
Thanks, @WazzaJB !
|
My setup looks like this:
VS Code (latest version - no updates available)
Prettier code formatter (6.4.0) - Installed via VS Code extensions
Prettier/plugin-php - installed globally using:
npm install --global prettier @prettier/plugin-php
My VS code setting.json file looks like this:
Yes when I try to format a .php file, using either format on save or smd-shift-p nothing happens, it has zero functionality. What am I doing wrong here? Is there an installation set that I missed?
Prettier is currently working as expected for .js files, it is only plug-php that I am having issues with.
The text was updated successfully, but these errors were encountered: