Inconsistency in Ormolu formatting #213
Labels
component: plugins
type: bug
Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
type: enhancement
New feature or request
Hey, sorry for opening yet another issue, I kinda feel guilty 😅 I noticed what appears to be a bug, and I took the opportunity to ask additional formatter-related questions, I can push them to other issues if it's simpler for you to manage.
I just tested in VS Code "Format document", which I assume relies on Ormolu (I configured the Ormolu formatter in
languageServerHaskell.formattingProvider
).1 - Format is bugged, and inconsistent
We see an inconsistency between applying "Format" from HLS (in VS Code) or applying Ormolu directly in CLI.
Consider this code:
Applying reformatting from VS Code (and I checked in HLS Output view that it uses Ormolu), this gets reformatted as such:
Note in particular that import order was modified, yet it's not completely alphabetical
Now run the formatter again in VS Code (yes, without modifying anything) and the second time, import order is correct! 💥
Now when running Ormolu in CLI, the original piece of code gets reformatted to:
i.e. Ormolu in CLI run once behaves the same as formatting twice in a row in VS Code 💥
Edit: the situation seems to be even worse. Here's an additional example:
Even after 50 reformats, the import order remains:
While Ormolu in CLI correctly returns:
2 - Is it a packaged version of Ormolu, or does it use the path one?
3 - Custom options
If I am correct, how would one pass custom options to Ormolu, like
--ghc-opt -XBangPatterns
? So far we were using Nix + a custom shell wrapper to force our own options as such:Would this still work/get picked up by HLS?
4 - Formatter (plugins) versions in HLS logs
Shouldn't the HLS logs display the formatter version? Currently there's no way to know which one is picked/used
I think the perfect opportunity would be at startup while listing plugins:
Thank you again for the help, quick replies, and overall support 🙏 Let me know if I can help (with my modest understanding of this project)
The text was updated successfully, but these errors were encountered: