haskell / stylish-haskell

Haskell code prettifier
Other
988 stars 151 forks source link

Make it possible to search for config without getCurrentDirectory #482

Closed jhrcek closed 4 months ago

jhrcek commented 4 months ago

An attempt to resolve https://github.com/haskell/stylish-haskell/issues/478

The intention is to make it possible to avoid dependency on getCurrentDirectory (which is problematic in haskell-language-server where multiple things running concurrently might depend on current directory and having to setCurrentDirectory just for stylish-haskell to be able to find the right config might lead to various race conditions).

The way to achieve it is to introduce new datatype ConfigSearchStrategy whose constructor SearchFromDirectory startDir makes it possible to supply a directory explicitly.

See this HLS PR for an example of how this new functionality would be used: https://github.com/haskell/haskell-language-server/pull/4338

jhrcek commented 4 months ago

Hello @jaspervdj could you please check this when you have some time?

jhrcek commented 4 months ago

Converting to draft while I'm groping in the dark, trying to make CI pass..

jaspervdj commented 4 months ago

Actually feel free to leave the CI changes out, I can try to get them in as a separate PR.

jhrcek commented 4 months ago

Ok, thank you. Forgive my sausage fingers, I wanted to force push (-f) the branch with CI change commits reset but instead I deleted the branch in my remote (-d) :sweat_smile: I reopened the PR in https://github.com/haskell/stylish-haskell/pull/483