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

Description

 

Synopsis

Documentation

asks :: (r -> a) -> Neovim r st a Source

Retrieve something from the configuration with respect to the first function. Works exactly like asks.

ask :: Neovim r st r Source

Retrieve the Cunfiguration (i.e. read-only state) from the Neovim context.

get :: MonadState s m => m s

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

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

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

type Neovim r st = StateT st (ReaderT (ConfigWrapper r) IO) 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.

type Neovim' = Neovim () () Source

Convenience alias for Neovim () ().

data ConfigWrapper a Source

A wrapper for a reader value that contains extra fields required to communicate with the messagepack-rpc components.

Constructors

ConfigWrapper 

Fields

_eventQueue :: TQueue SomeMessage

A queue of messages that the event handler will propagate to appropriate threads and handlers.

_quit :: MVar QuitAction

The main thread will wait for this MVar to be filled with a value and then perform an action appropriate for the value of type QuitAction.

_providerName :: String

Name that is used to identify this provider. Assigning such a name is done in the neovim config (e.g. ~/.nvim/nvimrc).

customConfig :: a

Plugin author supplyable custom configuration. It can be queried via myConf.

runNeovim :: ConfigWrapper r -> st -> Neovim r st a -> IO (Either String (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.

err :: String -> Neovim r st a Source

throw . ErrorMessage

restart :: Neovim r st () Source

Initiate a restart of the plugin provider.

quit :: Neovim r st () Source

Initiate the termination of the plugin provider.

data QuitAction Source

Constructors

Quit

Quit the plugin provider.

Restart

Restart the plugin provider.

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