@@ -28,10 +28,11 @@ import GHC.IO.Handle (hDuplicate)
28
28
import System.IO
29
29
import Control.Monad.Extra
30
30
31
+ import Development.IDE.Core.IdeConfiguration
32
+ import Development.IDE.Core.Shake
31
33
import Development.IDE.LSP.HoverDefinition
32
34
import Development.IDE.LSP.Notifications
33
35
import Development.IDE.LSP.Outline
34
- import Development.IDE.Core.Service
35
36
import Development.IDE.Types.Logger
36
37
import Development.IDE.Core.FileStore
37
38
import Language.Haskell.LSP.Core (LspFuncs (.. ))
@@ -105,8 +106,8 @@ runLanguageServer options userHandlers getIdeState = do
105
106
handlers <- parts WithMessage {withResponse, withNotification, withResponseAndRequest} def
106
107
107
108
let initializeCallbacks = LSP. InitializeCallbacks
108
- { LSP. onInitialConfiguration = const $ Right ()
109
- , LSP. onConfigurationChange = const $ Right ()
109
+ { LSP. onInitialConfiguration = Right . parseConfiguration
110
+ , LSP. onConfigurationChange = const $ Left " Configuration changes not supported yet "
110
111
, LSP. onStartup = handleInit (signalBarrier clientMsgBarrier () ) clearReqId waitForCancel clientMsgChan
111
112
}
112
113
@@ -121,9 +122,13 @@ runLanguageServer options userHandlers getIdeState = do
121
122
, void $ waitBarrier clientMsgBarrier
122
123
]
123
124
where
124
- handleInit :: IO () -> (LspId -> IO () ) -> (LspId -> IO () ) -> Chan Message -> LSP. LspFuncs () -> IO (Maybe err )
125
+ handleInit :: IO () -> (LspId -> IO () ) -> (LspId -> IO () ) -> Chan Message -> LSP. LspFuncs IdeConfiguration -> IO (Maybe err )
125
126
handleInit exitClientMsg clearReqId waitForCancel clientMsgChan lspFuncs@ LSP. LspFuncs {.. } = do
127
+
126
128
ide <- getIdeState getNextReqId sendFunc (makeLSPVFSHandle lspFuncs) clientCapabilities
129
+
130
+ mapM_ (registerIdeConfiguration (shakeExtras ide)) =<< config
131
+
127
132
_ <- flip forkFinally (const exitClientMsg) $ forever $ do
128
133
msg <- readChan clientMsgChan
129
134
case msg of
@@ -193,12 +198,12 @@ cancelHandler cancelRequest = PartialHandlers $ \_ x -> return x
193
198
-- | A message that we need to deal with - the pieces are split up with existentials to gain additional type safety
194
199
-- and defer precise processing until later (allows us to keep at a higher level of abstraction slightly longer)
195
200
data Message
196
- = forall m req resp . (Show m , Show req ) => Response (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (LSP. LspFuncs () -> IdeState -> req -> IO (Either ResponseError resp ))
201
+ = forall m req resp . (Show m , Show req ) => Response (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (LSP. LspFuncs IdeConfiguration -> IdeState -> req -> IO (Either ResponseError resp ))
197
202
-- | Used for cases in which we need to send not only a response,
198
203
-- but also an additional request to the client.
199
204
-- For example, 'executeCommand' may generate an 'applyWorkspaceEdit' request.
200
- | forall m rm req resp newReqParams newReqBody . (Show m , Show rm , Show req ) => ResponseAndRequest (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (RequestMessage rm newReqParams newReqBody -> FromServerMessage ) (LSP. LspFuncs () -> IdeState -> req -> IO (resp , Maybe (rm , newReqParams )))
201
- | forall m req . (Show m , Show req ) => Notification (NotificationMessage m req ) (LSP. LspFuncs () -> IdeState -> req -> IO () )
205
+ | forall m rm req resp newReqParams newReqBody . (Show m , Show rm , Show req ) => ResponseAndRequest (RequestMessage m req resp ) (ResponseMessage resp -> FromServerMessage ) (RequestMessage rm newReqParams newReqBody -> FromServerMessage ) (LSP. LspFuncs IdeConfiguration -> IdeState -> req -> IO (resp , Maybe (rm , newReqParams )))
206
+ | forall m req . (Show m , Show req ) => Notification (NotificationMessage m req ) (LSP. LspFuncs IdeConfiguration -> IdeState -> req -> IO () )
202
207
203
208
204
209
modifyOptions :: LSP. Options -> LSP. Options
0 commit comments