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.
- rpcStoreRef : Lean.Name → NonScalar → m Lean.Lsp.RpcRef
- rpcGetRef : Lean.Lsp.RpcRef → m (Option (Lean.Name × NonScalar))
- rpcReleaseRef : Lean.Lsp.RpcRef → m Bool
Monads with an RPC session in their state.
Equations
- One or more equations did not get rendered due to their size.
- rpcEncode : {m : Type → Type} → [inst : Monad m] → [inst : Lean.Server.MonadRpcSession m] → α → m β
- rpcDecode : {m : Type → Type} → [inst : Monad m] → [inst : Lean.Server.MonadRpcSession m] → β → ExceptT String m α
RpcEncoding α β means that α may participate in RPC calls with its on-the-wire LSP encoding
being β. This is useful when α contains fields which must be marshalled in a special way. In
particular, we encode WithRpcRef fields as opaque references rather than send their content.
Structures with From/ToJson use JSON as their RpcEncoding. Structures containing
non-JSON-serializable fields can be auto-encoded in two ways:
deriving RpcEncodingacts likeFrom/ToJsonbut marshalls anyWithRpcReffields asLsp.RpcRefs.deriving RpcEncoding with { withRef := true }generates an encoding forWithRpcRef TheType.
Instances
- Lean.Server.instRpcEncoding
- Lean.Widget.instRpcEncodingMsgToInteractiveRpcEncodingPacket
- Lean.Widget.instRpcEncodingSubexprInfoRpcEncodingPacket
- Lean.Server.instRpcEncodingOption
- Lean.Widget.instRpcEncodingInteractiveTermGoalRpcEncodingPacket
- Lean.Widget.instRpcEncodingInfoPopupRpcEncodingPacket
- Lean.Widget.TaggedText.instRpcEncodingTaggedText
- Lean.Widget.instRpcEncodingDiagnosticWithRpcEncodingPacket
- Lean.Widget.instRpcEncodingInteractiveHypothesisBundleRpcEncodingPacket
- Lean.Server.instRpcEncodingArray
- Lean.Widget.instRpcEncodingInteractiveGoalRpcEncodingPacket
- Lean.Server.instRpcEncodingProd
- Lean.Widget.instRpcEncodingMsgEmbedRpcEncodingPacket
- Lean.Widget.instRpcEncodingInteractiveGoalsRpcEncodingPacket
- Lean.Widget.instRpcEncodingWithRpcRefMessageDataRpcRef
- Lean.Widget.instRpcEncodingWithRpcRefInfoWithCtxRpcRef
- Lean.Widget.instRpcEncodingGetGoToLocationParamsRpcEncodingPacket
Equations
- Lean.Server.instRpcEncoding = { rpcEncode := fun {m} [Monad m] [Lean.Server.MonadRpcSession m] => pure, rpcDecode := fun {m} [Monad m] [Lean.Server.MonadRpcSession m] => pure }
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.
- val : α
Marks fields to encode as opaque references in LSP packets.
Equations
- Lean.Server.instInhabitedWithRpcRef = { default := { val := default } }
This is unsafe because we must ensure that:
- the stored
NonScalaris never used to access the value as a type other thanα - the type
αis not a scalar
Equations
- Lean.Server.WithRpcRef.encodeUnsafe typeName r = let obj := unsafeCast r.val; Lean.Server.rpcStoreRef typeName obj
Equations
- One or more equations did not get rendered due to their size.