prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.08k stars 450 forks source link

Feature Request: settings.json entry for plugins #2828

Open ChadBailey opened 1 year ago

ChadBailey commented 1 year ago

Is your feature request related to a problem? Please describe. When using prettier with non-javascript languages, it requires the setup of the plugin within the project's package.json as the docs indicate is required for plugin support. This makes sense when using prettier as a node module executed from the command line, but that doesn't make a lot of sense when using Prettier from the context of a visual studio extension. This problem is exasperated by the fact if you are intending to use a plugin, you likely aren't using JavaScript for that project.

Describe the solution you'd like I propose adding the following settings.json entry: "prettier.plugins":["@prettier/plugin-ruby","prettier-plugin-toml"] such that the array values are strings that match the string format expected by npm install - see this plugin list for the plugins I recommend being officially supported (but it could be designed in a generic way)

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

In an ideal world, this would be accompanied with logic to identify when the user is attempting to autoformat a document in a language supported by a plugin. If they didn't have the plugin the user would be prompted to download and add the plugin to their config rather than receiving this error

image

ntotten commented 1 year ago

TBH, this seems more like a feature of VSCode than it does this extension. Effectively something like recommended plugins but for modules.

Also, why not just include a package.json file with the required extensions?

github-actions[bot] commented 1 year ago

This bug is missing information needed to diagnose the problem. Please see our guide on how to open a good issue and provide the missing information. Most configuration-related issues can only be resolved by providing a full repro. If you don't provide a sample to reproduce your issue, your bug will most likely be closed.

ChadBailey commented 1 year ago

Effectively something like recommended plugins but for modules.

I'm not entirely sure you're fully understanding what I'm asking based on this (and by all means I could be the one confused here). I realize I didn't do my best job at making my request clear, so I'm going to rewrite the problem statement, here goes...

Problem Statement

When using prettier visual studio code extension for formatting any language supported through a 3rd party plugin, I must do that by installing node, configuring npm, and putting a package.json file in my project root. (Unless I'm misunderstanding the docs).

This is an issue for the following reasons:

Bottom line is, it's a bit nonsensical to have to create a package.json and install prettier+the sh plugin just to format a 10 line shell script.

ChadBailey commented 1 year ago

If this problem can be solved any other way, by all means go for it. I'm not married to the solution I suggested, I just want to be able to use prettier to format documents supported by extensions without polluting my local environment or having to install node.

I'm pretty sure I've seen other extensions have "plugins", they just create multiple extensions for each plugin then make an extension pack i.e. https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter

ssbarnea commented 1 year ago

I agree with @ChadBailey regarding the desired to not have to create a package.json, as not all projects using prettier are npm based. For example I use https://pre-commit.ci/ to run prettier and it does not require that, instead for prettier plugins it has an additional_dependencies field where you can specify them. See https://github.com/ansible/ansible-lint/blob/main/.pre-commit-config.yaml#L54-L57 as practical example of how pretter is configured with pre-commit tool. Still, the bad part is that this does not help the prettier extension in any way.

JounQin commented 1 year ago

Any progress on this? I imagined prettier.resolveGlobalModules setting should resolve plugins globally, however it seems not true. 😂

contentfree commented 9 months ago

Any ideas for this? I'm not using node so having a packages.json in my project just for a VS Code formatting plugin is a non-starter. How can one use a Prettier plugin (like the XML one) without packages.json?

Spongman commented 8 months ago

yeah, i don't have a package.json, how am i supposed to install plugins?