nvim-hs-0.0.6: Haskell plugin backend for neovim

Stabilityexperimental
Maintainerwoozletoff@gmail.com
Safe HaskellNone

Neovim.Context

Description

 

Synopsis

Documentation

newUniqueFunctionName :: Neovim r st FunctionNameSource

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

data 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.

Instances

MonadBase IO (Neovim r st) 
MonadReader r (Neovim r st)

User facing instance declaration for the reader state.

MonadState st (Neovim r st) 
Monad (Neovim r st) 
Functor (Neovim r st) 
Applicative (Neovim r st) 
MonadIO (Neovim r st) 
MonadThrow (Neovim r st) 
MonadMask (Neovim r st) 
MonadCatch (Neovim r st) 
MonadResource (Neovim r st) 

type Neovim' = Neovim () ()Source

Convenience alias for Neovim () ().

data NeovimException Source

Exceptions specific to nvim-hs.

Constructors

ErrorMessage Doc

Simply error message that is passed to neovim. It should currently only contain one line of text.

type FunctionMap = Map FunctionName FunctionMapEntrySource

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.)

type FunctionMapEntry = (FunctionalityDescription, FunctionType)Source

Type of the values stored in the function map.

mkFunctionMap :: [FunctionMapEntry] -> FunctionMapSource

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

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 ThreadIdSource

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.

err :: Doc -> Neovim r st aSource

throw specialized to Doc. If you do not care about pretty printing, you can simply use text in front of your string or use the OverloadedStrings extension to specify the error message.

restart :: Neovim r st ()Source

Initiate a restart of the plugin provider.

quit :: Neovim r st ()Source

Initiate the termination of the plugin provider.

ask :: MonadReader r m => m r

asks :: MonadReader r m => (r -> a) -> m a

get :: MonadState s m => m s

gets :: MonadState s m => (s -> a) -> m a

put :: MonadState s m => s -> m ()

modify :: MonadState s m => (s -> s) -> m ()

throwError :: MonadError e m => forall a. e -> m a