From dcf81a11d27171aae2197c7a9d903e106aa28b07 Mon Sep 17 00:00:00 2001 From: Luke Lau Date: Thu, 14 Nov 2019 18:17:50 +0000 Subject: [PATCH] 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. --- app/MainHie.hs | 11 +---------- src/Haskell/Ide/Engine/Transport/LspStdio.hs | 13 +++++++------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/MainHie.hs b/app/MainHie.hs index 9375f92eb..2af52bfc0 100644 --- a/app/MainHie.hs +++ b/app/MainHie.hs @@ -111,22 +111,13 @@ run opts = do Core.setupLogger mLogFileName ["hie", "hie-bios"] logLevel - d <- getCurrentDirectory - -- Get the cabal directory from the cradle - cradle <- findLocalCradle (d "File.hs") - - projGhcVersion <- getProjectGhcVersion cradle - when (projGhcVersion /= hieGhcVersion) $ - warningm $ "Mismatching GHC versions: Project is " ++ projGhcVersion - ++ ", HIE is " ++ hieGhcVersion - origDir <- getCurrentDirectory maybe (pure ()) setCurrentDirectory $ projectRoot opts progName <- getProgName logm $ "Run entered for HIE(" ++ progName ++ ") " ++ version - logm $ "Current directory:" ++ d + logm $ "Current directory:" ++ origDir args <- getArgs logm $ "args:" ++ show args diff --git a/src/Haskell/Ide/Engine/Transport/LspStdio.hs b/src/Haskell/Ide/Engine/Transport/LspStdio.hs index 926607f68..f74f8c8f4 100644 --- a/src/Haskell/Ide/Engine/Transport/LspStdio.hs +++ b/src/Haskell/Ide/Engine/Transport/LspStdio.hs @@ -420,8 +420,10 @@ reactor inp diagIn = do reactorSend $ NotLogMessage $ fmServerLogMessageNotification J.MtLog $ "Using hie version: " <> T.pack version - d <- liftIO getCurrentDirectory - cradle <- liftIO $ findLocalCradle (d "File.hs") + lspRootDir <- asksLspFuncs Core.rootPath + currentDir <- liftIO getCurrentDirectory + + cradle <- liftIO $ findLocalCradle ((fromMaybe currentDir lspRootDir) "File.hs") -- Check for mismatching GHC versions projGhcVersion <- liftIO $ getProjectGhcVersion cradle when (projGhcVersion /= hieGhcVersion) $ do @@ -437,13 +439,12 @@ reactor inp diagIn = do reactorSend $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning msg reactorSend $ NotLogMessage $ fmServerLogMessageNotification J.MtWarning msg - - lf <- ask + renv <- ask let hreq = GReq tn Nothing Nothing Nothing callback Nothing $ IdeResultOk <$> Hoogle.initializeHoogleDb - callback Nothing = flip runReaderT lf $ + callback Nothing = flip runReaderT renv $ reactorSend $ NotShowMessage $ fmServerShowMessageNotification J.MtWarning "No hoogle db found. Check the README for instructions to generate one" - callback (Just db) = flip runReaderT lf $ do + callback (Just db) = flip runReaderT renv $ do reactorSend $ NotLogMessage $ fmServerLogMessageNotification J.MtLog $ "Using hoogle db at: " <> T.pack db makeRequest hreq