@@ -11,7 +11,9 @@ module Development.IDE.Main
11
11
,Log (.. )
12
12
) where
13
13
14
- import Control.Concurrent.Extra (withNumCapabilities )
14
+ import Control.Concurrent.Extra (Chan , newChan ,
15
+ withNumCapabilities ,
16
+ writeChan )
15
17
import Control.Concurrent.MVar (newEmptyMVar ,
16
18
putMVar , tryReadMVar )
17
19
import Control.Concurrent.STM.Stats (dumpSTMStats )
@@ -63,6 +65,7 @@ import Development.IDE.Graph (action)
63
65
import Development.IDE.LSP.LanguageServer (runLanguageServer ,
64
66
setupLSP )
65
67
import qualified Development.IDE.LSP.LanguageServer as LanguageServer
68
+ import Development.IDE.LSP.Server
66
69
import Development.IDE.Main.HeapStats (withHeapStats )
67
70
import qualified Development.IDE.Main.HeapStats as HeapStats
68
71
import qualified Development.IDE.Monitoring.EKG as EKG
@@ -356,19 +359,26 @@ defaultMain recorder Arguments{..} = withHeapStats (cmapWithPrio LogHeapStats re
356
359
putMVar ideStateVar ide
357
360
pure ide
358
361
359
- let setup = setupLSP (cmapWithPrio LogLanguageServer recorder) argsGetHieDbLoc (pluginHandlers plugins) getIdeState
362
+ -- Send everything over a channel, since you need to wait until after initialise before
363
+ -- LspFuncs is available
364
+ clientMsgChan :: Chan ReactorMessage <- newChan
365
+
366
+ let setup = setupLSP (cmapWithPrio LogLanguageServer recorder) argsGetHieDbLoc (pluginHandlers plugins) getIdeState clientMsgChan
360
367
-- See Note [Client configuration in Rules]
361
368
onConfigChange cfg = do
362
369
-- TODO: this is nuts, we're converting back to JSON just to get a fingerprint
363
370
let cfgObj = J. toJSON cfg
364
- mide <- liftIO $ tryReadMVar ideStateVar
365
- case mide of
366
- Nothing -> pure ()
367
- Just ide -> liftIO $ do
368
- let msg = T. pack $ show cfg
369
- logDebug (Shake. ideLogger ide) $ " Configuration changed: " <> msg
370
- modifyClientSettings ide (const $ Just cfgObj)
371
- setSomethingModified Shake. VFSUnmodified ide [toKey Rules. GetClientSettings emptyFilePath] " config change"
371
+ let configChangeIO = do
372
+ mide <- liftIO $ tryReadMVar ideStateVar
373
+ case mide of
374
+ Nothing -> pure ()
375
+ Just ide -> liftIO $ do
376
+ let msg = T. pack $ show cfg
377
+ logDebug (Shake. ideLogger ide) $ " Configuration changed: " <> msg
378
+ modifyClientSettings ide (const $ Just cfgObj)
379
+ setSomethingModified Shake. VFSUnmodified ide [toKey Rules. GetClientSettings emptyFilePath] " config change"
380
+ liftIO $ writeChan clientMsgChan $ ReactorNotification configChangeIO
381
+
372
382
373
383
runLanguageServer (cmapWithPrio LogLanguageServer recorder) options inH outH argsDefaultHlsConfig argsParseConfig onConfigChange setup
374
384
dumpSTMStats
0 commit comments