Skip to content

Commit dcf81a1

Browse files
lukel97mpickering
authored andcommitted
Use the LSP provided root directory to find the cradle
When checking for GHC version. This also removes the redundant check in MainHie (I'm not sure why were checking twice). This will remove the check for the JSON transport, but as far as I am aware this is unmantained anyway.
1 parent 714f42a commit dcf81a1

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

app/MainHie.hs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,13 @@ run opts = do
111111

112112
Core.setupLogger mLogFileName ["hie", "hie-bios"] logLevel
113113

114-
d <- getCurrentDirectory
115-
-- Get the cabal directory from the cradle
116-
cradle <- findLocalCradle (d </> "File.hs")
117-
118-
projGhcVersion <- getProjectGhcVersion cradle
119-
when (projGhcVersion /= hieGhcVersion) $
120-
warningm $ "Mismatching GHC versions: Project is " ++ projGhcVersion
121-
++ ", HIE is " ++ hieGhcVersion
122-
123114
origDir <- getCurrentDirectory
124115

125116
maybe (pure ()) setCurrentDirectory $ projectRoot opts
126117

127118
progName <- getProgName
128119
logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version
129-
logm $ "Current directory:" ++ d
120+
logm $ "Current directory:" ++ origDir
130121
args <- getArgs
131122
logm $ "args:" ++ show args
132123

src/Haskell/Ide/Engine/Transport/LspStdio.hs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,10 @@ reactor inp diagIn = do
420420
reactorSend $ NotLogMessage $
421421
fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack version
422422

423-
d <- liftIO getCurrentDirectory
424-
cradle <- liftIO $ findLocalCradle (d </> "File.hs")
423+
lspRootDir <- asksLspFuncs Core.rootPath
424+
currentDir <- liftIO getCurrentDirectory
425+
426+
cradle <- liftIO $ findLocalCradle ((fromMaybe currentDir lspRootDir) </> "File.hs")
425427
-- Check for mismatching GHC versions
426428
projGhcVersion <- liftIO $ getProjectGhcVersion cradle
427429
when (projGhcVersion /= hieGhcVersion) $ do
@@ -437,13 +439,12 @@ reactor inp diagIn = do
437439
reactorSend $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning msg
438440
reactorSend $ NotLogMessage $ fmServerLogMessageNotification J.MtWarning msg
439441

440-
441-
lf <- ask
442+
renv <- ask
442443
let hreq = GReq tn Nothing Nothing Nothing callback Nothing $ IdeResultOk <$> Hoogle.initializeHoogleDb
443-
callback Nothing = flip runReaderT lf $
444+
callback Nothing = flip runReaderT renv $
444445
reactorSend $ NotShowMessage $
445446
fmServerShowMessageNotification J.MtWarning "No hoogle db found. Check the README for instructions to generate one"
446-
callback (Just db) = flip runReaderT lf $ do
447+
callback (Just db) = flip runReaderT renv $ do
447448
reactorSend $ NotLogMessage $
448449
fmServerLogMessageNotification J.MtLog $ "Using hoogle db at: " <> T.pack db
449450
makeRequest hreq

0 commit comments

Comments
 (0)