Skip to content

.ormolu files are ignored when formatting with Ormolu #3448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sir4ur0n opened this issue Jan 9, 2023 · 0 comments · Fixed by #3449
Closed

.ormolu files are ignored when formatting with Ormolu #3448

sir4ur0n opened this issue Jan 9, 2023 · 0 comments · Fixed by #3449
Labels
component: formatters type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@sir4ur0n
Copy link
Collaborator

sir4ur0n commented Jan 9, 2023

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

  1. Create a file .ormolu as per Ormolu's documentation containing:
infixl 7 .=?

  1. Have a Haskell file containing:
(.=?) :: String -> String -> String
s1 .=? s2 = s1 <> s2

infixl 7 .=?

foo :: String
foo = "a" .=? "b"
    <> "c" .=? "d" <> "e" .=? "f"
  1. 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"
  1. 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.

@sir4ur0n sir4ur0n added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs triage labels Jan 9, 2023
@mergify mergify bot closed this as completed in #3449 Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: formatters type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
2 participants