prettier-vscode icon indicating copy to clipboard operation
prettier-vscode copied to clipboard

Language Overrides for printWidth Setting in VS Code

Open dbagley1 opened this issue 1 year ago • 10 comments

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.

image

Additional context Language-specific options set in VS Code settings.json would look like: image

Relevant VS Code Documentation: https://code.visualstudio.com/api/references/contribution-points#Configuration-property-schema

dbagley1 avatar Jul 26 '23 21:07 dbagley1

It should support overrides fields anyway. https://prettier.io/docs/en/configuration.html#setting-the-parserdocsenoptionshtmlparser-option

GongT avatar Jul 27 '23 03:07 GongT

@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.

dbagley1 avatar Aug 03 '23 20:08 dbagley1

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!

danlutz avatar Sep 21 '23 10:09 danlutz

Agree with @dbagley1. I add that all configuration options should have the scope language-overridable.

SomaticIT avatar Sep 25 '23 10:09 SomaticIT

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. 😉

benblank avatar Oct 04 '23 23:10 benblank

I've submitted a pull request to add support for per-language printWidth configuration #3178

dbagley1 avatar Oct 17 '23 17:10 dbagley1

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

github-actions[bot] avatar Dec 17 '23 01:12 github-actions[bot]

Waiting for feedback from reviewers on my pull request. This issue remains unresolved @ntotten

dbagley1 avatar Dec 17 '23 21:12 dbagley1

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

github-actions[bot] avatar Feb 17 '24 01:02 github-actions[bot]

Replying to keep this issue open.

dbagley1 avatar Feb 17 '24 02:02 dbagley1

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.

github-actions[bot] avatar Jun 20 '24 00:06 github-actions[bot]