Description
Your environment
Which OS do you use?
NixOS
Which version of GHC do you use and how did you install it?
9.0.2 from Nix (branch nixos-22.11
).
How is your project built (alternative: link to the project)?
With Cabal (the project is private).
Which LSP client (editor/plugin) do you use?
emacs+lsp-mode
Which version of HLS do you use and how did you install it?
1.8.0.0
from Nix (branch nixos-22.11
).
Have you configured HLS in any way (especially: a hie.yaml
file)?
Yes, with hie.yaml
. I think the configuration is correct because everything seems to work (type info, lenses, code actions, completion, go to definition, find references, etc.).
Steps to reproduce
- Create a file
.ormolu
as per Ormolu's documentation containing:
infixl 7 .=?
- Have a Haskell file containing:
(.=?) :: String -> String -> String
s1 .=? s2 = s1 <> s2
infixl 7 .=?
foo :: String
foo = "a" .=? "b"
<> "c" .=? "d" <> "e" .=? "f"
- Format from the command line:
$ ormolu path/to/my/file.hs
The format is as expected:
foo :: String
foo =
"a" .=? "b"
<> "c" .=? "d"
<> "e" .=? "f"
- Format from the editor (e.g. in Emacs:
M-x lsp-format-buffer
), the format is different (does not seem to take into account.ormolu
file):
foo :: String
foo =
"a"
.=? "b"
<> "c"
.=? "d"
<> "e"
.=? "f"
Expected behaviour
Formatting behaves exactly the same from the CLI and from the LSP.
Actual behaviour
LSP behavior is different.
My assumption is that LSP does not format the file, but formats using stdin
. In that case, as per Ormolu documentation, the LSP should pass --stdin-input-file <file name>
option to Ormolu to help it detect the .ormolu
file.
This is obviously just a guess 😅 Maybe I'm completely wrong.