haskell / haskell/haskell-language-server
Allow disabling the formattingProvider
- Dominant language
- Haskell
- Stars
- 3k
- Forks
- 455
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 11
Description
## Is your enhancement request related to a problem? Please describe.
Disabling the `formattingProvider` configuration does not seem possible. There is a handful of options but it can't be disabled.
The current implementation reacts formatting requests and then figures out there is plugin available. It will then result in an error


### Options
> Formatting provider (haskell.formattingProvider, default ormolu): what formatter to use; one of floskell, ormolu, fourmolu, stylish-haskell, or brittany (if compiled with the brittany plugin).
https://github.com/haskell/haskell-language-server/blob/aee737237c7f4542bddc7ab31a2bdd7ee0cab48d/docs/configuration.md#language-specific-server-options
### Why would one want to disable the formattingProvider?
Followup of https://github.com/haskell/haskell-language-server/issues/3282
In order to configure a separate generic language server (https://github.com/iamcco/diagnostic-languageserver) to deal with formatting, Haskell language server should not "catch" the formatting requests. Instead it has to be possible to disable formatting without completely disabling the language server.
Another possibility would be - this is a bit made up - that people could have arbitrary reasons to to configure no "formattingProvider", e.g. they have configured "format on save" or they often press the format shortcut out of habit, but don't want formatting to happen temporarily for a specific or Haskell projects in general.
## Describe the solution you'd like
Either `""` or `"none"` should be handled in a way where the language server behaves as if the formatting handler wouldn't be implemented.
* Ideally the server capabilities wouldn't include formatting when no formatting provider is configured
* An alternative solution would be a Noop-Formatter, that requests requests in a way where they're not "swallowed" (from lsp client perspective). Downside is to add a plugin that does nothing, but would allow other code places to not care about formatting.
* Another alternative is to not fail with an error in case no plugin for the formatting request was found, and the config is set to "none".
Maybe it is as simple as this...
```haskell
when (formattingProvider config == "none") $
pure $ Left $ ResponseError MethodNotFound "No formattingProvider configured" Nothing
```
## Additional context
There is a test that defines how `"none"` is handled. It succeeds for `MethodNotFound` but also `""No plugin enabled for STextDocumentFormatting""` what is shown above. But this is not the wanted behavior since from the LSP client's perspective the request was handled.
https://github.com/haskell/haskell-language-server/blob/b378de2d42d1c78d0119d54e65646b475a9dc6c5/test/functional/Format.hs#L54
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.