Documentation

Lean.Server.Rpc.Basic

Allows LSP clients to make Remote Procedure Calls to the server.

The single use case for these is to allow the infoview UI to refer to and manipulate heavy-weight objects residing on the server. It would be inefficient to serialize these into JSON and send over. For example, the client can format an Expr without transporting the whole Environment.

All RPC requests are relative to an open file and an RPC session for that file. The client must first connect to the session using $/lean/rpc/connect.

An object which RPC clients can refer to without marshalling.

Instances For
    • Objects that are being kept alive for the RPC client, together with their type names, mapped to by their RPC reference.

      Note that we may currently have multiple references to the same object. It is only disposed of once all of those are gone. This simplifies the client a bit as it can drop every reference received separately.

    • nextRef : USize

      Value to use for the next RpcRef. It is monotonically increasing to avoid any possible bugs resulting from its reuse.

    Instances For
      Equations
      Instances For
        Equations
        Instances For
          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            RpcEncodable α means that α can be deserialized from and serialized into JSON for the purpose of receiving arguments to and sending return values from Remote Procedure Calls (RPCs).

            Any type with FromJson and ToJson instances is RpcEncodable.

            Furthermore, types that do not have these instances may still be RpcEncodable. Use deriving RpcEncodable to automatically derive instances for such types.

            This occurs when α contains data that should not or cannot be serialized: for instance, heavy objects such as Lean.Environment, or closures. For such data, we use the WithRpcRef marker. Note that for WithRpcRef α to be RpcEncodable, α must have a TypeName instance

            On the server side, WithRpcRef α is just a structure containing a value of type α. On the client side, it is an opaque reference of (structural) type Lsp.RpcRef. Thus, WithRpcRef α is cheap to transmit over the network but may only be accessed on the server side. In practice, it is used by the client to pass data between various RPC methods provided by the server.

            Instances
              Equations
              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.
              Equations
              • One or more equations did not get rendered due to their size.
              structure Lean.Server.WithRpcRef (α : Type u) :

              Marks values to be encoded as opaque references in RPC packets.

              See the docstring for RpcEncodable.

              • val : α
              Instances For
                Equations
                • Lean.Server.instInhabitedWithRpcRef = { default := { val := default } }
                Equations
                • Lean.Server.instRpcEncodableWithRpcRef = { rpcEncode := Lean.Server.instRpcEncodableWithRpcRef.rpcEncode, rpcDecode := Lean.Server.instRpcEncodableWithRpcRef.rpcDecode }
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For