nvim-hs-0.1.1: Haskell plugin backend for neovim

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

Neovim.Context.Internal

Description

To shorten function and data type names, import this qualfied as Internal.

Synopsis

Documentation

newtype Neovim r st a Source #

This is the environment in which all plugins are initially started. Stateless functions use '()' for the static configuration and the mutable state and there is another type alias for that case: Neovim'.

Functions have to run in this transformer stack to communicate with neovim. If parts of your own functions dont need to communicate with neovim, it is good practice to factor them out. This allows you to write tests and spot errors easier. Essentially, you should treat this similar to IO in general haskell programs.

Constructors

Neovim 

Fields

Instances

MonadBase IO (Neovim r st) Source # 

Methods

liftBase :: IO α -> Neovim r st α #

MonadReader r (Neovim r st) Source #

User facing instance declaration for the reader state.

Methods

ask :: Neovim r st r #

local :: (r -> r) -> Neovim r st a -> Neovim r st a #

reader :: (r -> a) -> Neovim r st a #

MonadState st (Neovim r st) Source # 

Methods

get :: Neovim r st st #

put :: st -> Neovim r st () #

state :: (st -> (a, st)) -> Neovim r st a #

Monad (Neovim r st) Source # 

Methods

(>>=) :: Neovim r st a -> (a -> Neovim r st b) -> Neovim r st b #

(>>) :: Neovim r st a -> Neovim r st b -> Neovim r st b #

return :: a -> Neovim r st a #

fail :: String -> Neovim r st a #

Functor (Neovim r st) Source # 

Methods

fmap :: (a -> b) -> Neovim r st a -> Neovim r st b #

(<$) :: a -> Neovim r st b -> Neovim r st a #

Applicative (Neovim r st) Source # 

Methods

pure :: a -> Neovim r st a #

(<*>) :: Neovim r st (a -> b) -> Neovim r st a -> Neovim r st b #

(*>) :: Neovim r st a -> Neovim r st b -> Neovim r st b #

(<*) :: Neovim r st a -> Neovim r st b -> Neovim r st a #

MonadIO (Neovim r st) Source # 

Methods

liftIO :: IO a -> Neovim r st a #

MonadThrow (Neovim r st) Source # 

Methods

throwM :: Exception e => e -> Neovim r st a #

MonadCatch (Neovim r st) Source # 

Methods

catch :: Exception e => Neovim r st a -> (e -> Neovim r st a) -> Neovim r st a #

MonadMask (Neovim r st) Source # 

Methods

mask :: ((forall a. Neovim r st a -> Neovim r st a) -> Neovim r st b) -> Neovim r st b #

uninterruptibleMask :: ((forall a. Neovim r st a -> Neovim r st a) -> Neovim r st b) -> Neovim r st b #

MonadResource (Neovim r st) Source # 

Methods

liftResourceT :: ResourceT IO a -> Neovim r st a #

ask' :: Neovim r st (Config r st) Source #

Same as ask for the InternalConfig.

asks' :: (Config r st -> a) -> Neovim r st a Source #

Same as asks for the InternalConfig.

type Neovim' = Neovim () () Source #

Convenience alias for Neovim () ().

runNeovim :: Config r st -> st -> Neovim r st a -> IO (Either Doc (a, st)) Source #

Initialize a Neovim context by supplying an InternalEnvironment.

forkNeovim :: ir -> ist -> Neovim ir ist a -> Neovim r st ThreadId Source #

Fork a neovim thread with the given custom config value and a custom state. The result of the thread is discarded and only the ThreadId is returend immediately. FIXME This function is pretty much unused and mayhave undesired effects, namely that you cannot register autocmds in the forked thread.

newUniqueFunctionName :: Neovim r st FunctionName Source #

Create a new unique function name. To prevent possible name clashes, digits are stripped from the given suffix.

data FunctionType Source #

This data type is used to dispatch a remote function call to the appopriate recipient.

Constructors

Stateless ([Object] -> Neovim' Object)

Stateless functions are simply executed with the sent arguments.

Stateful (TQueue SomeMessage)

Stateful functions are handled within a special thread, the TQueue is the communication endpoint for the arguments we have to pass.

type FunctionMapEntry = (FunctionalityDescription, FunctionType) Source #

Type of the values stored in the function map.

type FunctionMap = Map FunctionName FunctionMapEntry 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.)

mkFunctionMap :: [FunctionMapEntry] -> FunctionMap Source #

Create a new function map from the given list of FunctionMapEntry values.

data Config r st Source #

A wrapper for a reader value that contains extra fields required to communicate with the messagepack-rpc components and provide necessary data to provide other globally available operations.

Note that you most probably do not want to change the fields prefixed with an underscore.

Constructors

Config 

Fields

retypeConfig :: r -> st -> Config anotherR anotherSt -> Config r st Source #

Convenient helper to create a new config for the given state and read-only config.

Sets the pluginSettings field to Nothing.

data PluginSettings r st where Source #

This GADT is used to share informatino between stateless and stateful plugin threads since they work fundamentally in the same way. They both contain a function to register some functionality in the plugin provider as well as some values which are specific to the one or the other context.

newConfig :: IO (Maybe String) -> IO r -> IO (Config r context) Source #

Create a new InternalConfig object by providing the minimal amount of necessary information.

This function should only be called once per nvim-hs session since the arguments are shared across processes.

data StateTransition Source #

The state that the plugin provider wants to transition to.

Constructors

Quit

Quit the plugin provider.

Restart

Restart the plugin provider.

Failure Doc

The plugin provider failed to start or some other error occured.

InitSuccess

The plugin provider started successfully.