ribosome-host-0.9.9.9: Neovim plugin host for Polysemy
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ribosome.Host.Effect.Rpc

Synopsis

Documentation

data Rpc :: Effect where Source #

This effect abstracts interaction with the Neovim RPC API. An RPC call can either be a request or a notification, where the former expects a response to be sent while the latter returns immediately.

For requests, the constructor sync blocks the current thread while async takes a callback that is called from a new thread.

The constructor notify sends a notification.

The module Ribosome.Api.Data contains RpcCalls for the entire Neovim API, generated by calling neovim --api-info during compilation from Template Haskell.

The module Ribosome.Api contains functions that call sync with those RpcCalls, converting the input and return values to and from msgpack.

These functions have signatures like:

nvimGetVar :: ∀ a r . Member Rpc r => MsgpackDecode a => Text -> Sem r a

A manual call would be constructed like this:

Ribosome.sync (RpcCallRequest (Request "nvim_get_option" [toMsgpack "textwidth"]))

RPC calls may be batched and sent via nvim_call_atomic, see RpcCall.

This effect's default interpreter uses Resumable for error tracking. See Errors.

Constructors

Sync :: RpcCall a -> Rpc m a

Block the current thread while sending an RPC request.

Async :: RpcCall a -> (Either RpcError a -> m ()) -> Rpc m ()

Send an RPC request and pass the result to the continuation on a new thread.

Notify :: RpcCall a -> Rpc m ()

Send an RPC notification and return immediately.

ChannelId :: Rpc m ChannelId

The Neovim RPC channel ID

sync :: forall r a. Member Rpc r => RpcCall a -> Sem r a Source #

Block the current thread while sending an RPC request.

async :: forall a r. Member Rpc r => RpcCall a -> (Either RpcError a -> Sem r ()) -> Sem r () Source #

Send an RPC request and pass the result to the continuation on a new thread.

notify :: forall a r. Member Rpc r => RpcCall a -> Sem r () Source #

Send an RPC notification and return immediately.

channelId :: forall r. Member Rpc r => Sem r ChannelId Source #

The Neovim RPC channel ID