-
Notifications
You must be signed in to change notification settings - Fork 81
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
Use .cabal or cabal.project to discover which files to format #1054
Comments
Thanks, sounds interesting! It is not immediately clear to me if there is a simple way to implement the An alternative might be to allow to pass a list of
I am not sure what you are trying to say here: Ormolu can't format My preferred way to list Haskell source files for e.g. Ormolu to format is via fd, i.e. |
I think it'd be nice to also have the |
A heuristic would be to only use those *.cabal files that are both listed in
Ah, I didn't know that! Nevermind then. I would have thought it could format literate Haskell, but I didn't research this.
Compare e.g. Rust with |
If this is easy to implement then it may still be worth doing it, maybe new, simpler usage patterns will arise! I would definitely use such a feature. |
Follow-up issue from fourmolu/fourmolu#348.
It would be great if, instead of having to specify files to format via a directory or a complicated call to
git
,ormolu
would simply detect the files to format in the same waycabal
does. Basically, if the commandcabal build all --enable-tests --enable-benchmarks
would read a particular Haskell source file, thenormolu -i
should format that file.Why the current situation is not good enough
For any particular project, I can somehow adapt the
ormolu
call. But when I want to automatize (e.g. to write a goodgit
alias, or a github action), I want to be able to deal with any sort of Haskell project.Specifying a directory
The docs recommend e.g.
ormolu -i src
. This doesn't work for projects that have several folders (e.g.test
,benchmark
,app
) generically because a project might have any sort of folders. Also, it doesn't work when you have acabal.project
structure.git ls-files
The docs recommend
ormolu --mode inplace $(git ls-files '*.hs')
, but this doesn't work in general because there might be other files like*.lhs
,*.md
. Also, it doesn't work if there is no git repository (e.g. downloading a tarball).find
The docs recommend
ormolu --mode inplace $(find . -name '*.hs')
, but this doesn't always work out of the box because there may bedist-newstyle
or other build folders which I don't want to format.What would be the most straightforward way
Like
cabal
, ormolu should automatically discover whether there is a*.cabal
file, and then format all of the Haskell source files specified in it, or if there is acabal.project
file, format all the source files found from all the cabal projects in there. Advantages:The text was updated successfully, but these errors were encountered: