prettier-vscode
prettier-vscode copied to clipboard
Language Overrides for printWidth Setting in VS Code
Problem Allow language overrides for the VS Code prettier.printWidth option. VS Code settings are easily synchronized between machines and virtual environments like GitHub Codespaces. User-level Prettier configurations are more difficult to keep synchronized between environments leading to inconsistent formatting.
Solution Update the extension manifest to specify the language-overridable scope on the prettier.printWidth option.
Additional context
Language-specific options set in VS Code settings.json would look like:
Relevant VS Code Documentation: https://code.visualstudio.com/api/references/contribution-points#Configuration-property-schema
It should support overrides
fields anyway. https://prettier.io/docs/en/configuration.html#setting-the-parserdocsenoptionshtmlparser-option
@GongT You're referring to the prettier configuration option. This issue is about the language-level overrides in VS Code because VS Code settings can be set on a user level that syncs between devices.
Also experiencing this problem. We have language specific overrides for printWidth settings in the prettier configuration file. Works fine when formatting using the CLI, but the "Format Document" or "Format On Save" option in VSCode does not respect this override.
Update: The solution described by @dbagley1 worked for me!
Agree with @dbagley1.
I add that all configuration options should have the scope language-overridable
.
I've just run into this limitation myself: I change printWidth
to 120 in the general case (I primarily use Prettier with source code, which I do believe benefits from longer lines), but strongly prefer to use a more conservative width of 80 for documents (such as Markdown).
To be honest, this feels like a bit of a "regression" compared to the CLI, which allows for per-language (by way of globs, anyway) configuration both when using .prettierrc
and when using .editorconfig
. Of course, Prettier's lack of global configuration means it can't really be customized when editing files outside of projects at all without using prettier-vscode or similar! I just want to have the best of both worlds. 😉
I've submitted a pull request to add support for per-language printWidth configuration #3178
This issue has been labeled as stale due to inactivity. Reply to keep this issue open.
Waiting for feedback from reviewers on my pull request. This issue remains unresolved @ntotten
This issue has been labeled as stale due to inactivity. Reply to keep this issue open.
Replying to keep this issue open.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.