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).
Why would one want to disable the formattingProvider?
Followup of #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...
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.