ghc-mod should be told which version of cabal to use #1373
Description
The below was found when using HIE on a cabal v2 project in which the top level directory had a cabal.project with packages in subdirectories containing the .cabal files. I would invoke neovim/hie from the project directory and open a file for editing such as $TOP/$package/src/file.hs
.
ghc-mod uses cabal configure
or new-configure
conditionally based on a heuristic of checking for dist-newstyle
in a working directory (see core/GhcMod/CabalHelper.hs
for the config vs new-config and core/GhcMod/Cradle
for the directory heuristic). If no newstyle directory is found it assumes v1.
- I will ask ghc-mod to default assume v2 instead of v1.
- ghc-mod uses the current working directory (due to withGhcModEnv or findCradle depending on code path). We need to be able to tell ghc-mod the directory. This will requires a ghc-mod patch which is then leveraged by hie. Does that sound good?
A quicker fix for HIE might be to not change the working directory to begin with... not sure where that is done honestly. I start neovim/hie-wrapper in the top level directory (project) but clearly ghc-mod is seeing the subdirectory (package).