@@ -36,7 +36,7 @@ import GHC.Paths
37main :: IO ()
37main :: IO ()
39− (ghcOptions, map toNormalizedFilePath -> files) <- getCmdLine
39+ (ghcOptions, map toNormalizedFilePath -> files, isIde) <- getCmdLine
41 -- lock to avoid overlapping output on stdout
41 -- lock to avoid overlapping output on stdout
42 lock <- newLock
42 lock <- newLock
@@ -52,8 +52,10 @@ main = do
52 ,optShakeProfiling = Nothing -- Just "output.html"
52 ,optShakeProfiling = Nothing -- Just "output.html"
55− if null files then
55+ if isIde then do
56+ putStrLn "Starting IDE server"
56− runLanguageServer logger $ \event vfs ->
57+ runLanguageServer logger $ \event vfs -> do
58+ putStrLn "Server started"
57 initialise mainRule event logger options vfs
59 initialise mainRule event logger options vfs
59 vfs <- makeVFSHandle
61 vfs <- makeVFSHandle
@@ -92,16 +94,17 @@ newSession flags = runGhc (Just libdir) $ do
94-- | Convert the command line into GHC options and files to load.
96-- | Convert the command line into GHC options and files to load.
95−getCmdLine :: IO ([String], [FilePath])
97+getCmdLine :: IO ([String], [FilePath], Bool)
96getCmdLine = do
98getCmdLine = do
97 args <- getArgs
99 args <- getArgs
100+ let isIde = "--ide" `elem` args
98− args <- return $ if null args then [".ghci"] else args
101+ args <- return $ delete "--ide" $ if null args then [".ghci"] else args
99 let (flags, files) = partition ("-" `isPrefixOf`) args
102 let (flags, files) = partition ("-" `isPrefixOf`) args
100 let (ghci, hs) = partition ((==) ".ghci" . takeExtension) files
103 let (ghci, hs) = partition ((==) ".ghci" . takeExtension) files
101 (flags, files) <- both concat . unzip . ((flags,hs):) <$> mapM readGhci ghci
104 (flags, files) <- both concat . unzip . ((flags,hs):) <$> mapM readGhci ghci
102 when (null files) $
105 when (null files) $
103 fail "Expected some files to load, but didn't find any"
106 fail "Expected some files to load, but didn't find any"
104− return (flags, files)
107+ return (flags, files, isIde)
106readGhci :: FilePath -> IO ([String], [FilePath])
109readGhci :: FilePath -> IO ([String], [FilePath])
107readGhci file = do
110readGhci file = do