-
-
Notifications
You must be signed in to change notification settings - Fork 456
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
Add plugin support #757
Add plugin support #757
Conversation
Closes prettier#395 Closes prettier#612
81de68e
to
fd6fdfc
Compare
Nice work! Would this in theory allow us .NET folks to format our |
Yeah. It should support all prettier plugins. |
I tried to add global plugin support here But there's an issue in requiring the global prettier. I tried to use the Btw, I still think this PR is ready to merge. It's better than no plugin support and we can add the global plugin support in later PR. In fact I can open a draft PR from above commit for discussion immediately after this one merged. |
Found a workaround esamattis@dff3734 This PR now has a working plugin support using a global Prettier installation too. It prefers local one if it is found. Here's a .vsix build for testing https://github.com/epeli/prettier-vscode/releases/download/global-plugins-support/prettier-vscode-1.8.99-prerelease.vsix |
Thank you guys for putting effort into this function! I'm having a little trouble with prettier-plugin-apex though... I've installed prettier and the apex plugin globally,
but vs code still tells me that
Any ideas? PS: I'm using the vsix uploaded by @epeli above.
|
Does it work with a local installation? |
@epeli I'm afraid no... got the same error message from vs code
|
Can you provide an example file that can be formatted using the CLI? I could not find even a working hello world example (no idea what's apex). |
@epeli An example could be https://github.com/forcedotcom/sfdx-simple Tested under macOS and Linux, same results |
I can't seem to get this to work with global prettier + prettier-plugin-toml, are there any specific configuration parameters I need to set? |
So yeah, I got busted for using Windows at home. 🤦♂️ I have macbook at work and it's broken here indeed. My workaround for the @Frederick888 But I tried hard coding the global node_modules paths and the apex formatter seems to work ok. I don't understand why it does not work locally for you though. It working fine for me. Do you have the @Southclaws The TOML plugin seems to be incomplete. It does not implement |
@epeli No, I'm using https://marketplace.visualstudio.com/items?itemName=salesforce.salesforcedx-vscode from Salesforce. Is that extension required for Prettier to work? |
Some extension is required because vscode has to know about the file type. Wonder if that extension exposes the type under different id? |
Weird. It is working for me with the |
Next attempt: This version is using |
Here's one more prerelease which displays an error message if a given plugin is missing FYI: You can also open vscode developer tools to see more detailed logging of which prettier is being used. |
@epeli Just tested 1.8.102 under Linux and it worked like charm! Thanks, mate! PS: Prettier and Apex plugin were installed globally, only salesforce.salesforcedx-vscode extension was installed. |
I added a 'Show Output Channel' command which displays the messages from the output channel. The used prettier instance is now logged to it. Also I found it useful when using the alpha releases of the plugins because they might itself cause prettier to crash so now it is possible to see the error messages they produce. I also tested the new requireg workaround on Windows too. So this should be now working on macOS, Windows and Linux. Here's prerelease again |
@epeli Tested on MacOS and looks to be working great with Thanks for the great work. |
Hey, thanks for working on that. Resolution:
Anything which wouldn't be covered ? |
How soon can we use this please? |
Installed locally and seems to be working fine with prettier-plugin-java |
Can you please tell me what I need to do to have it running? |
I installed the plugin as a dev dependency in the project then you need to set your settings to use the prettier for formatting your java files:
|
Thanks. I installed prettier prettier-plugin-ruby and set [ruby].editor.defaultFormatter like you said. It still says no formatter found for ruby files. |
Same here. Latest viscose and latest prettier and latest ruby plugin. I'm on macOS. I still get that there's no formatter for ruby files. All sources point to this PR as being the definitive solution. Also, this workaround works indeed. |
Hi, |
Installing the extension from this PR I was able to use the prettier-plugin-solidity. |
@nicosampler did you have issues with the indentation being 2 spaces instead of 4 as I did? |
prettier-vscode/src/PrettierEditProvider.ts Line 196 in 4570b5d
Editing this line fixes #878. { ...fileOptions, filepath: fileName }, |
#817 solves this issue and provides tests so let's proceed with that PR to get this issue resolved. |
Closes #395
Closes #612
It works by checking language support from each workspace that has a local Prettier installation and registers all supported languages as language formatters.
There's one caveat though. If you have multiple workspaces that have different prettier plugins installed you will get error message that a plugin is not installed if you try to format file in a workspace that does not have it installed but some other workspace has. I don't think there's a way around this because vscode registers formatters globally.
Prelease build from this PR: https://github.com/epeli/prettier-vscode/releases/download/1.8.103-prerelease/prettier-vscode-1.8.103-prerelease.vsix
Install with