@@ -12,7 +12,7 @@ module Development.IDE.Main
12
12
) where
13
13
14
14
import Control.Concurrent.Extra (withNumCapabilities )
15
- import Control.Concurrent.MVar (newEmptyMVar ,
15
+ import Control.Concurrent.MVar (MVar , newEmptyMVar ,
16
16
putMVar , tryReadMVar )
17
17
import Control.Concurrent.STM.Stats (dumpSTMStats )
18
18
import Control.Monad.Extra (concatMapM , unless ,
@@ -318,9 +318,8 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
318
318
ioT <- offsetTime
319
319
logWith recorder Info $ LogLspStart (pluginId <$> ipMap argsHlsPlugins)
320
320
321
- ideStateVar <- newEmptyMVar
322
- let getIdeState :: LSP. LanguageContextEnv Config -> FilePath -> WithHieDb -> Shake. ThreadQueue -> IO IdeState
323
- getIdeState env rootPath withHieDb threadQueue = do
321
+ let getIdeState :: MVar IdeState -> LSP. LanguageContextEnv Config -> FilePath -> WithHieDb -> Shake. ThreadQueue -> IO IdeState
322
+ getIdeState ideStateVar env rootPath withHieDb threadQueue = do
324
323
t <- ioT
325
324
logWith recorder Info $ LogLspStartDuration t
326
325
sessionLoader <- loadSessionWithOptions (cmapWithPrio LogSession recorder) argsSessionLoadingOptions rootPath (tLoaderQueue threadQueue)
@@ -353,9 +352,9 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
353
352
putMVar ideStateVar ide
354
353
pure ide
355
354
356
- let setup = setupLSP (cmapWithPrio LogLanguageServer recorder) argsProjectRoot argsGetHieDbLoc (pluginHandlers plugins) getIdeState
355
+ let setup ideStateVar = setupLSP (cmapWithPrio LogLanguageServer recorder) argsProjectRoot argsGetHieDbLoc (pluginHandlers plugins) ( getIdeState ideStateVar)
357
356
-- See Note [Client configuration in Rules]
358
- onConfigChange cfg = do
357
+ onConfigChange ideStateVar cfg = do
359
358
-- TODO: this is nuts, we're converting back to JSON just to get a fingerprint
360
359
let cfgObj = J. toJSON cfg
361
360
mide <- liftIO $ tryReadMVar ideStateVar
@@ -368,7 +367,9 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
368
367
modifyClientSettings ide (const $ Just cfgObj)
369
368
return [toNoFileKey Rules. GetClientSettings ]
370
369
371
- runLanguageServer (cmapWithPrio LogLanguageServer recorder) options inH outH argsDefaultHlsConfig argsParseConfig onConfigChange setup
370
+ do
371
+ ideStateVar <- newEmptyMVar
372
+ runLanguageServer (cmapWithPrio LogLanguageServer recorder) options inH outH argsDefaultHlsConfig argsParseConfig (onConfigChange ideStateVar) (setup ideStateVar)
372
373
dumpSTMStats
373
374
Check argFiles -> do
374
375
let dir = argsProjectRoot
0 commit comments