@@ -53,7 +53,6 @@ import Control.Monad.Trans.State (StateT, runStateT, execState)
53
53
import qualified Control.Monad.Trans.State as State
54
54
import qualified Data.ByteString.Lazy.Char8 as B
55
55
import Data.Aeson hiding (Error , Null )
56
- import qualified Data.Aeson as J
57
56
import Data.Aeson.Encode.Pretty
58
57
import Data.Aeson.Lens ()
59
58
import Data.Conduit as Conduit
@@ -115,8 +114,8 @@ data SessionConfig = SessionConfig
115
114
-- ^ Trace the messages sent and received to stdout, defaults to False.
116
115
-- Can be overriden with the environment variable @LSP_TEST_LOG_MESSAGES@.
117
116
, logColor :: Bool -- ^ Add ANSI color to the logged messages, defaults to True.
118
- , lspConfig :: Value
119
- -- ^ The initial LSP config as JSON value, defaults to Null .
117
+ , lspConfig :: Object
118
+ -- ^ The initial LSP config as JSON value, defaults to the empty object .
120
119
-- This should include the config section for the server if it has one, i.e. if
121
120
-- the server has a 'mylang' config section, then the config should be an object
122
121
-- with a 'mylang' key whose value is the actual config for the server. You
@@ -134,7 +133,7 @@ data SessionConfig = SessionConfig
134
133
135
134
-- | The configuration used in 'Language.LSP.Test.runSession'.
136
135
defaultConfig :: SessionConfig
137
- defaultConfig = SessionConfig 60 False False True J. Null True True Nothing
136
+ defaultConfig = SessionConfig 60 False False True mempty True True Nothing
138
137
139
138
instance Default SessionConfig where
140
139
def = defaultConfig
@@ -188,9 +187,9 @@ data SessionState = SessionState
188
187
-- Used for providing exception information
189
188
, lastReceivedMessage :: ! (Maybe FromServerMessage )
190
189
, curDynCaps :: ! (Map. Map T. Text SomeRegistration )
191
- , curLspConfig :: Value
192
190
-- ^ The capabilities that the server has dynamically registered with us so
193
191
-- far
192
+ , curLspConfig :: Object
194
193
, curProgressSessions :: ! (Set. Set ProgressToken )
195
194
, ignoringLogNotifications :: Bool
196
195
, ignoringConfigurationRequests :: Bool
@@ -317,24 +316,20 @@ updateStateC = awaitForever $ \msg -> do
317
316
sendMessage $ TResponseMessage " 2.0" (Just $ r ^. L. id ) (Right $ ApplyWorkspaceEditResult True Nothing Nothing )
318
317
FromServerMess SMethod_WorkspaceConfiguration r -> do
319
318
let requestedSections = mapMaybe (\ i -> i ^? L. section . _Just) $ r ^. L. params . L. items
320
- c <- curLspConfig <$> get @ SessionState
321
- case c of
322
- Object o -> do
323
- -- check for each requested section whether we have it
324
- let configsOrErrs = (flip fmap ) requestedSections $ \ section ->
325
- case o ^. at (fromString $ T. unpack section) of
326
- Just config -> Right config
327
- Nothing -> Left section
328
-
329
- let (errs, configs) = partitionEithers configsOrErrs
330
-
331
- -- we have to return exactly the number of sections requested, so if we can't find all of them then that's an error
332
- if null errs
333
- then sendMessage $ TResponseMessage " 2.0" (Just $ r ^. L. id ) (Right configs)
334
- else sendMessage @ _ @ (TResponseError Method_WorkspaceConfiguration ) $
335
- TResponseError (InL LSPErrorCodes_RequestFailed ) (" No configuration for requested sections: " <> (T. pack $ show errs)) Nothing
336
-
337
- _ -> sendMessage @ _ @ (TResponseError Method_WorkspaceConfiguration ) $ TResponseError (InL LSPErrorCodes_RequestFailed ) " No configuration" Nothing
319
+ o <- curLspConfig <$> get @ SessionState
320
+ -- check for each requested section whether we have it
321
+ let configsOrErrs = (flip fmap ) requestedSections $ \ section ->
322
+ case o ^. at (fromString $ T. unpack section) of
323
+ Just config -> Right config
324
+ Nothing -> Left section
325
+
326
+ let (errs, configs) = partitionEithers configsOrErrs
327
+
328
+ -- we have to return exactly the number of sections requested, so if we can't find all of them then that's an error
329
+ if null errs
330
+ then sendMessage $ TResponseMessage " 2.0" (Just $ r ^. L. id ) (Right configs)
331
+ else sendMessage @ _ @ (TResponseError Method_WorkspaceConfiguration ) $
332
+ TResponseError (InL LSPErrorCodes_RequestFailed ) (" No configuration for requested sections: " <> (T. pack $ show errs)) Nothing
338
333
_ -> pure ()
339
334
unless ((ignoringLogNotifications state && isLogNotification msg) || (ignoringConfigurationRequests state && isConfigRequest msg)) $
340
335
yield msg
0 commit comments