Always emit all kinds of diagnostic, `-W` just changes severity
Summary
HLS relies on certain GHC diagnostics (mostly warnings) in order to offer people fixes for the corresponding issues.
The problem is that if someone does not have the warning on, then the feature does not work.
For example, if a user does not have the redundant imports warning on, then HLS will not offer to remove them (it doesn't know they're redundant!).
See https://github.com/haskell/haskell-language-server/issues/2064
I wonder if this could be improved on the GHC side. AIUI, the way things work today is:
- If a warning flag is not enabled, then no diagnostic is emitted at all.
An alternative approach would be:
- Diagnostics are always emitted, but by default at a lower severity ("Info"?) which is not shown by default (but is present if you use the GHC API)
- A warning flag simply changes the severity of the diagnostic from Info to Warning
That way HLS would always see all the diagnostics that GHC can produce about a file, even if the user doesn't want to see them as warnings.