Documentation

Lean.Server.Requests

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
  • One or more equations did not get rendered due to their size.
def Lean.Server.parseRequestParams (paramType : Type) [inst : Lean.FromJson paramType] (params : Lean.Json) :
Equations
  • One or more equations did not get rendered due to their size.
@[inline]
abbrev Lean.Server.RequestTask (α : Type u_1) :
Type u_1
Equations
@[inline]
abbrev Lean.Server.RequestM (α : Type) :
Type

Workers execute request handlers in this monad.

Equations
Equations
  • One or more equations did not get rendered due to their size.
def Lean.Server.RequestM.mapTask {α : Type u_1} {β : Type} (t : Task α) (f : αLean.Server.RequestM β) :
Equations

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.
def Lean.Server.registerLspRequestHandler (method : String) (paramType : Type) [inst : Lean.FromJson paramType] [inst : Lean.Lsp.FileSource paramType] (respType : Type) [inst : Lean.ToJson respType] (handler : paramTypeLean.Server.RequestM (Lean.Server.RequestTask respType)) :

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 the RequestM monad and is expected to produce an asynchronous RequestTask 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.
def Lean.Server.chainLspRequestHandler (method : String) (paramType : Type) [inst : Lean.FromJson paramType] (respType : Type) [inst : Lean.FromJson respType] [inst : Lean.ToJson respType] (handler : paramTypeLean.Server.RequestTask respTypeLean.Server.RequestM (Lean.Server.RequestTask respType)) :

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.