nvim-hs-1.0.0.2: 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 env a Source #

This is the environment in which all plugins are initially started.

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

MonadReader env (Neovim env) Source #

User facing instance declaration for the reader state.

Methods

ask :: Neovim env env #

local :: (env -> env) -> Neovim env a -> Neovim env a #

reader :: (env -> a) -> Neovim env a #

Monad (Neovim env) Source # 

Methods

(>>=) :: Neovim env a -> (a -> Neovim env b) -> Neovim env b #

(>>) :: Neovim env a -> Neovim env b -> Neovim env b #

return :: a -> Neovim env a #

fail :: String -> Neovim env a #

Functor (Neovim env) Source # 

Methods

fmap :: (a -> b) -> Neovim env a -> Neovim env b #

(<$) :: a -> Neovim env b -> Neovim env a #

Applicative (Neovim env) Source # 

Methods

pure :: a -> Neovim env a #

(<*>) :: Neovim env (a -> b) -> Neovim env a -> Neovim env b #

liftA2 :: (a -> b -> c) -> Neovim env a -> Neovim env b -> Neovim env c #

(*>) :: Neovim env a -> Neovim env b -> Neovim env b #

(<*) :: Neovim env a -> Neovim env b -> Neovim env a #

MonadIO (Neovim env) Source # 

Methods

liftIO :: IO a -> Neovim env a #

MonadUnliftIO (Neovim env) Source # 

Methods

askUnliftIO :: Neovim env (UnliftIO (Neovim env)) #

withRunInIO :: ((forall a. Neovim env a -> IO a) -> IO b) -> Neovim env b #

MonadResource (Neovim env) Source # 

Methods

liftResourceT :: ResourceT IO a -> Neovim env a #

MonadThrow (Neovim env) Source # 

Methods

throwM :: Exception e => e -> Neovim env a #

ask' :: Neovim env (Config env) Source #

Same as ask for the InternalConfig.

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

Same as asks for the InternalConfig.

runNeovim :: NFData a => Config env -> Neovim env a -> IO (Either (Doc AnsiStyle) a) Source #

Initialize a Neovim context by supplying an InternalEnvironment.

runNeovimInternal :: (a -> IO a) -> Config env -> Neovim env a -> IO (Either (Doc AnsiStyle) a) Source #

newUniqueFunctionName :: Neovim env FunctionName Source #

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

newtype FunctionType Source #

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

Constructors

Stateful (TQueue SomeMessage)

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

Instances

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 env 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 :: env -> Config anotherEnv -> Config env Source #

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

Sets the pluginSettings field to Nothing.

data PluginSettings env where Source #

This GADT is used to share information 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 env -> IO (Config env) 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 AnsiStyle)

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

InitSuccess

The plugin provider started successfully.