Open
Conversation
The Prettier CLI has a `--parser` option for manually specifying the parser if needed, but the Prettier VSCode extension does not have a corresponding setting for specifying a parser in the VSCode `settings.json`. It also is not able to use custom language modes that have been set in VSCode (i.e., if a YAML file has been set as a `helm-template`). A parser setting would also be helpful for "untrusted" VSCode workspaces (workspaces running in "Restricted Mode"). Starting with version 12.4.0, untrusted workspaces now no longer load Prettier configuration files. However, they can still load `settings.json`, so Prettier settings can be added to `settings.json` for those workspaces. This PR will add a `prettier.parser` setting. The setting can be used in conjunction with language-specific settings to override the parser for specific VSCode languages. Alternatively, setting `prettier.parser: "vscode"` will derive the parser from the active VSCode language mode. Tests will be updated for the new setting and behavior. There are some small updates to config file parsing needed to properly respect the `.do-not-use-prettier-vscode-root` marker files. Signed-off-by: Brendon Smith <bws@bws.bio>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Prettier CLI has a
--parseroption for manually specifying the parser if needed, but the Prettier VSCode extension does not have a corresponding setting for specifying a parser in the VSCodesettings.json. It is also not able to use custom language modes that have been set in VSCode (i.e., if a YAML file has been set as ahelm-template).A parser setting would also be helpful for "untrusted" VSCode workspaces (workspaces running in "Restricted Mode"). Starting with version 12.4.0 (#3972), untrusted workspaces now no longer load Prettier configuration files. However, they can still load
settings.json, so Prettier settings can be added tosettings.jsonfor those workspaces.This PR will add a
prettier.parsersetting.The setting can be used in conjunction with language-specific settings to override the parser for specific VSCode languages. For example, to format Git commits and tags as Markdown, which can be useful for changelogs and docs:
{ "[git-commit]": { "prettier.parser": "markdown", "prettier.printWidth": 72, "prettier.proseWrap": "always" } }Alternatively, setting
prettier.parser: "vscode"will derive the parser from the active VSCode language mode.Tests will be updated for the new setting and behavior. There are some small updates to config file parsing needed to properly respect the
.do-not-use-prettier-vscode-rootmarker files.Related Issue
Type of Change
Checklist
npm run lintpasses)npm run prettierto format my codenpm test)