Send a warning when using the implicit cradle (#799)

* Send a warning when using the implicit cradle

* Implicit cradle

Co-authored-by: Neil Mitchell <ndmitchell@gmail.com>

Co-authored-by: Neil Mitchell <ndmitchell@gmail.com>
This commit is contained in:
Pepe Iborra 2020-09-14 22:43:10 +01:00 committed by GitHub
parent 7d9d2a5f0a
commit b7c9d6da2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -250,14 +250,18 @@ loadSession dir = do
let consultCradle :: Maybe FilePath -> FilePath -> IO ([NormalizedFilePath], (IdeResult HscEnvEq, [FilePath]))
consultCradle hieYaml cfp = do
when optTesting $ eventer $ notifyCradleLoaded cfp
logInfo logger $ T.pack ("Consulting the cradle for " <> show cfp)
lfp <- flip makeRelative cfp <$> getCurrentDirectory
logInfo logger $ T.pack ("Consulting the cradle for " <> show lfp)
when (isNothing hieYaml) $ eventer $ notifyUserImplicitCradle lfp
cradle <- maybe (loadImplicitHieCradle $ addTrailingPathSeparator dir) loadCradle hieYaml
-- Display a user friendly progress message here: They probably don't know what a
-- cradle is
when optTesting $ eventer $ notifyCradleLoaded lfp
-- Display a user friendly progress message here: They probably don't know what a cradle is
let progMsg = "Setting up " <> T.pack (takeBaseName (cradleRootDir cradle))
<> " (for " <> T.pack cfp <> ")"
<> " (for " <> T.pack lfp <> ")"
eopts <- withIndefiniteProgress progMsg NotCancellable $
cradleToOptsAndLibDir cradle cfp
@ -670,6 +674,14 @@ getCacheDir prefix opts = getXdgDirectory XdgCache (cacheDir </> prefix ++ "-" +
cacheDir :: String
cacheDir = "ghcide"
notifyUserImplicitCradle:: FilePath -> FromServerMessage
notifyUserImplicitCradle fp =
NotShowMessage $
NotificationMessage "2.0" WindowShowMessage $ ShowMessageParams MtWarning $
"No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for "
<> T.pack fp <>
".\n Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie)"
notifyCradleLoaded :: FilePath -> FromServerMessage
notifyCradleLoaded fp =
NotCustomServer $