We maintain a global map of LSP request handlers. This allows user code such as plugins to register its own handlers, for example to support ITP functionality such as goal state visualization.
For details of how to register one, see registerLspRequestHandler
.
Equations
- Lean.Server.RequestError.fileChanged = { code := Lean.JsonRpc.ErrorCode.contentModified, message := "File changed." }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Server.RequestError.instCoeErrorRequestError = { coe := fun e => { code := Lean.JsonRpc.ErrorCode.internalError, message := toString e } }
Equations
- Lean.Server.RequestError.toLspResponseError id e = { id := id, code := e.code, message := e.message, data? := none }
Equations
- One or more equations did not get rendered due to their size.
- rpcSessions : Std.RBMap UInt64 (IO.Ref Lean.Server.FileWorker.RpcSession) compare
- srcSearchPath : Lean.SearchPath
- hLog : IO.FS.Stream
- initParams : Lean.Lsp.InitializeParams
Equations
Workers execute request handlers in this monad.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Server.instMonadLiftIORequestM = { monadLift := fun {α} x => liftM (IO.toEIO (fun e => { code := Lean.JsonRpc.ErrorCode.internalError, message := toString e }) x) }
Equations
- Lean.Server.RequestM.asTask t rc = do let t ← liftM (EIO.asTask (t rc) Task.Priority.default) pure (Task.map liftExcept t)
Equations
- Lean.Server.RequestM.mapTask t f rc = do let t ← liftM (EIO.mapTask (fun a => f a rc) t Task.Priority.default) pure (Task.map liftExcept t)
Equations
- Lean.Server.RequestM.bindTask t f rc = liftM (EIO.bindTask t (fun a => f a rc) Task.Priority.default)
Equations
- One or more equations did not get rendered due to their size.
Create a task which waits for the first snapshot matching p
, handles various errors,
and if a matching snapshot was found executes x
with it. If not found, the task executes
notFoundX
.
Equations
- One or more equations did not get rendered due to their size.
See withWaitFindSnap
.
Equations
- One or more equations did not get rendered due to their size.
- fileSource : Lean.Json → Except Lean.Server.RequestError Lean.Lsp.DocumentUri
- handle : Lean.Json → Lean.Server.RequestM (Lean.Server.RequestTask Lean.Json)
NB: This method may only be called in builtin_initialize
blocks.
A registration consists of:
- a type of JSON-parsable request data
paramType
- a
FileSource
instance for it so the system knows where to route requests - a type of JSON-serializable response data
respType
- an actual
handler
which runs in theRequestM
monad and is expected to produce an asynchronousRequestTask
which does any waiting/computation
A handler task may be cancelled at any time, so it should check the cancellation token when possible to handle this cooperatively. Any exceptions thrown in a request handler will be reported to the client as LSP error responses.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Server.lookupLspRequestHandler method = do let a ← ST.Ref.get Lean.Server.requestHandlers pure (Std.PersistentHashMap.find? a method)
NB: This method may only be called in builtin_initialize
blocks.
Register another handler to invoke after the last one registered for a method. At least one handler for the method must have already been registered to perform chaining.
For more details on the registration of a handler, see registerLspRequestHandler
.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.