@@ -97,7 +97,7 @@ instance MonadLsp c m => MonadLsp c (IdentityT m) where
9797data LanguageContextEnv config =
9898 LanguageContextEnv
9999 { resHandlers :: ! (Handlers IO )
100- , resParseConfig :: ! (J. Value -> IO (Either T. Text config ))
100+ , resParseConfig :: ! (config -> J. Value -> (Either T. Text config ))
101101 , resSendMessage :: ! (FromServerMessage -> IO () )
102102 -- We keep the state in a TVar to be thread safe
103103 , resState :: ! (TVar (LanguageContextState config ))
@@ -168,7 +168,7 @@ data LanguageContextState config =
168168 LanguageContextState
169169 { resVFS :: ! VFSData
170170 , resDiagnostics :: ! DiagnosticStore
171- , resConfig :: ! ( Maybe config )
171+ , resConfig :: ! config
172172 , resWorkspaceFolders :: ! [WorkspaceFolder ]
173173 , resProgressData :: ! ProgressData
174174 , resPendingResponses :: ! ResponseMap
@@ -274,12 +274,15 @@ data ProgressCancellable = Cancellable | NotCancellable
274274-- specific configuration data the language server needs to use.
275275data ServerDefinition config = forall m a .
276276 ServerDefinition
277- { onConfigurationChange :: J. Value -> m (Either T. Text config )
278- -- ^ @onConfigurationChange newConfig@ is called whenever the
277+ { defaultConfig :: config
278+ -- ^ The default value we initialize the config variable to.
279+ , onConfigurationChange :: config -> J. Value -> Either T. Text config
280+ -- ^ @onConfigurationChange oldConfig newConfig@ is called whenever the
279281 -- clients sends a message with a changed client configuration. This
280282 -- callback should return either the parsed configuration data or an error
281283 -- indicating what went wrong. The parsed configuration object will be
282284 -- stored internally and can be accessed via 'config'.
285+ -- It is also called on the `initializationOptions` field of the InitializeParams
283286 , doInitialize :: LanguageContextEnv config -> Message Initialize -> IO (Either ResponseError a )
284287 -- ^ Called *after* receiving the @initialize@ request and *before*
285288 -- returning the response. This callback will be invoked to offer the
@@ -427,7 +430,7 @@ freshLspId = do
427430
428431-- | The current configuration from the client as set via the @initialize@ and
429432-- @workspace/didChangeConfiguration@ requests.
430- getConfig :: MonadLsp config m => m ( Maybe config )
433+ getConfig :: MonadLsp config m => m config
431434getConfig = getsState resConfig
432435
433436getClientCapabilities :: MonadLsp config m => m J. ClientCapabilities
0 commit comments