nvim-hs-0.0.1: Haskell plugin backend for neovim

Copyright(c) Sebastian Witte
LicenseApache-2.0
Maintainerwoozletoff@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Neovim.RPC.Common

Description

 

Synopsis

Documentation

type FunctionMap = Map Text FunctionType Source

A function map is a map containing the names of functions as keys and some context dependent value which contains all the necessary information to execute that function in the intended way.

This type is only used internally and handles two distinct cases. One case is a direct function call, wich is simply a function that accepts a list of Object values and returns a result in the Neovim context. The second case is calling a function that has a persistent state. This is mediated to a thread that reads from a TQueue. (NB: persistent currently means, that state is stored for as long as the plugin provider is running and not restarted.)

data RPCConfig Source

Things shared between the socket reader and the event handler.

Constructors

RPCConfig 

Fields

recipients :: TVar (Map Int64 (UTCTime, TMVar (Either Object Object)))

A map from message identifiers (as per RPC spec) to a tuple with a timestamp and a TMVar that is used to communicate the result back to the calling thread.

functions :: TMVar FunctionMap

A map that contains the function names which are registered to this plugin manager. Putting the map in a TMVar ensures that all functionality is registered properly before answering to requests send by neovim.

newRPCConfig :: (Applicative io, MonadIO io) => io RPCConfig Source

Create a new basic configuration containing a communication channel for remote procedure call events and an empty lookup table for functions to mediate.

data SocketType Source

Simple data type defining the kind of socket the socket reader should use.

Constructors

Stdout Handle

Use the handle for receiving msgpack-rpc messages. This is suitable for an embedded neovim which is used in test cases.

Environment

Read the connection information from the environment variable NVIM_LISTEN_ADDRESS.

UnixSocket FilePath

Use a unix socket.

TCP Int String

Use an IP socket. First argument is the port and the second is the host name.

createHandle :: (Functor io, MonadIO io) => IOMode -> SocketType -> io Handle Source

Create a Handle from the given socket description.

The handle is not automatically closed.

cleanUpHandle :: MonadIO io => Handle -> Bool -> io () Source