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
Zed forces Prettier to opt out of its usual parser inference #11517
Comments
Thank you for noticing. Changing this indeed cleans up the code and plugin configs: #11558 but has one side-effect: now, there's no opt-into prettier setting for any languages, and with the default, So I wonder, should we still keep some language plugin config for explicing prettier opt-in? cc @mrnugget as you were touching prettier integration recently too. |
Thanks for tagging, @SomeoneToIgnore! Few thoughts:
|
Good point, will get rid of it and replace with some boolean. |
Does it actually belong at the language level (i.e., in the language config)? It seems to me that some languages that may have a Prettier formatter could also have other formatters that could be used. And it seems problematic if the language itself governs whether or not Prettier should be used. Should we make this a language setting instead so that it is user-configurable? |
Closes #11517 * Removes forced prettier parser name for languages, making `auto` command to run prettier on every file by default. * Moves prettier configs away from plugin language declarations into language settings Release Notes: - N/A
Closes zed-industries#11517 * Removes forced prettier parser name for languages, making `auto` command to run prettier on every file by default. * Moves prettier configs away from plugin language declarations into language settings Release Notes: - N/A
Check for existing issues
Describe the bug / provide steps to reproduce it
When formatting a file using its native Prettier integration, Zed sends a
parser
option to Prettier based on Zed's understanding of the file's language. Prettier usually infers which parser to use based on the file path, but Zed's behavior causes Prettier to opt out of this inference.I don't think this is desirable behavior, because it can cause Zed to format files differently than Prettier would when invoked in other ways (e.g., via CLI).
One example is that Prettier special-cases
package.json
files, formatting them using thejson-stringify
parser rather than thejson
parser. But Zed overrides this behavior by forcing Prettier to use thejson
parser even for package.json files:This means that Zed's Prettier integration formats package.json differently than Prettier does when invoked via CLI, causing a mismatch whenever a package.json file is edited with Zed.
This could be fixed by teaching Zed about all of Prettier's various special cases, but that seems like a continuous maintenance burden that Zed probably doesn't want to take on.
Alternatively, maybe Zed doesn't need to pass the
parser
option at all. I think this was necessary prior to #9598, because there was a bug in the integration that prevented the file path from being passed along, preventing parser inference. But with that bug fixed, Prettier should be able to decide on the right parser to use from the file path alone.Environment
Zed: v0.133.7 (Zed)
OS: macOS 14.4.1
Memory: 96 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your
~/Library/Logs/Zed/Zed.log
file to this issue.No response
The text was updated successfully, but these errors were encountered: