yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Remove formatting provider

Open remcohaszing opened this issue 2 years ago • 6 comments

Is your enhancement related to a problem? Please describe.

yaml-language-server supports formatting YAML files. Under the hood this delegates the formatting to Pretttier. However, this integration is very limited. It doesn’t support Prettier options or a Prettier configuration file.

Additionally, the dependency on Prettier is huge. This isn’t great when yaml-language-server is used as part of a web bundle.

Describe the solution you would like

Remove the formatting provider entirely. Maybe recommend Prettier and their official VS Code extension instead in the readme.

Describe alternatives you have considered

Keep the formatting provider and close this issue.

Additional context

remcohaszing avatar Oct 27 '23 10:10 remcohaszing

I am not against the idea. There is a lot of users who are not happy with the prettier based formatter. My concern is the silent crowd who are happy with it. If we can devise a plan that will allow them to replace the function they depend on easily that would be ideal.

gorkem avatar Nov 06 '23 00:11 gorkem

I mostly reported this, because I’ve seen other users complain here as well as in relation to monaco-yaml.

Prettier has an Editor Integration page which lists several editor integrations.

Unfortunately there’s no Prettier language server (that I know of).

For Monaco editor I would be willing to create a Prettier integration if there’s user demand.

It’s also possible for yaml-language-server to provide a formatter based on YAML.stringify instead. That would mean formatting is still possible, but the formatted output will be different.

remcohaszing avatar Nov 07 '23 16:11 remcohaszing

I really like using prettier for yaml formatting, but it needs to respect .editorconfig / .prettierrc.

This can be set up with prettierd for most usecases, but it would be preferable for yaml-language-server to support formatting.

A way to "make everyone happy" would be to break out prettier support as a plugin, so that users can choose which formatting provider yaml-language-server invokes (or to choose none and have a minimal yaml-language-server installation)

That being said, it seems like a decent chunk of work, and I'm currently disabling yaml-language-server's formatting, so I wouldn't be upset about a decision to remove it completely

znd4 avatar Nov 08 '23 19:11 znd4

I also like using Prettier, but it’s a generic formatter that supports a bunch of languages. For them YAML is just one of them. Better integrations already exist.

I think it’s the responsibility of an editor to allow the user to pick a formatter, not that of a language server. I.e. VS Code supports this using the per language editor.defaultFormatter setting. I don’t think it’s a good idea to add a plugin system to yaml-language-server, because I see the editor as the plugin system and yaml-language-server as the plugin.

remcohaszing avatar Nov 16 '23 09:11 remcohaszing

I replaced Prettier an alternative formatter in #983. I think that caters to the silent crowd who just want to have some formatting options, but probably don’t care about the implementation used.

remcohaszing avatar Jul 24 '24 09:07 remcohaszing