Copyright | (c) Sebastian Witte |
---|---|
License | Apache-2.0 |
Maintainer | woozletoff@gmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
To shorten function and data type names, import this qualfied as Internal
.
Synopsis
- newtype Neovim env a = Neovim {}
- ask' :: Neovim env (Config env)
- asks' :: (Config env -> a) -> Neovim env a
- exceptionHandlers :: [Handler IO (Either (Doc ann) a)]
- runNeovim :: NFData a => Config env -> Neovim env a -> IO (Either (Doc AnsiStyle) a)
- runNeovimInternal :: (a -> IO a) -> Config env -> Neovim env a -> IO (Either (Doc AnsiStyle) a)
- newUniqueFunctionName :: Neovim env FunctionName
- newtype FunctionType = Stateful (TQueue SomeMessage)
- type FunctionMapEntry = (FunctionalityDescription, FunctionType)
- type FunctionMap = Map NvimMethod FunctionMapEntry
- mkFunctionMap :: [FunctionMapEntry] -> FunctionMap
- data Config env = Config {}
- retypeConfig :: env -> Config anotherEnv -> Config env
- data PluginSettings env where
- StatefulSettings :: (FunctionalityDescription -> ([Object] -> Neovim env Object) -> TQueue SomeMessage -> TVar (Map NvimMethod ([Object] -> Neovim env Object)) -> Neovim env (Maybe FunctionMapEntry)) -> TQueue SomeMessage -> TVar (Map NvimMethod ([Object] -> Neovim env Object)) -> PluginSettings env
- newConfig :: IO (Maybe String) -> IO env -> IO (Config env)
- data StateTransition
Documentation
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.
Instances
MonadReader env (Neovim env) Source # | User facing instance declaration for the reader state. |
Monad (Neovim env) Source # | |
Functor (Neovim env) Source # | |
MonadFail (Neovim env) Source # | |
Defined in Neovim.Context.Internal | |
Applicative (Neovim env) Source # | |
Defined in Neovim.Context.Internal | |
MonadIO (Neovim env) Source # | |
Defined in Neovim.Context.Internal | |
MonadUnliftIO (Neovim env) Source # | |
Defined in Neovim.Context.Internal | |
MonadResource (Neovim env) Source # | |
Defined in Neovim.Context.Internal liftResourceT :: ResourceT IO a -> Neovim env a # | |
MonadThrow (Neovim env) Source # | |
Defined in Neovim.Context.Internal |
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.
Stateful (TQueue SomeMessage) |
|
Instances
Pretty FunctionType Source # | |
Defined in Neovim.Context.Internal pretty :: FunctionType -> Doc ann # prettyList :: [FunctionType] -> Doc ann # |
type FunctionMapEntry = (FunctionalityDescription, FunctionType) Source #
Type of the values stored in the function map.
type FunctionMap = Map NvimMethod 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.
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.
Config | |
|
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.
StatefulSettings :: (FunctionalityDescription -> ([Object] -> Neovim env Object) -> TQueue SomeMessage -> TVar (Map NvimMethod ([Object] -> Neovim env Object)) -> Neovim env (Maybe FunctionMapEntry)) -> TQueue SomeMessage -> TVar (Map NvimMethod ([Object] -> Neovim env Object)) -> PluginSettings env |
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.
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. |
Instances
Show StateTransition Source # | |
Defined in Neovim.Context.Internal showsPrec :: Int -> StateTransition -> ShowS # show :: StateTransition -> String # showList :: [StateTransition] -> ShowS # |