ribosome-0.9.9.9: Neovim plugin framework for Polysemy
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ribosome.Interpreter.VariableWatcher

Description

Interpreters for VariableWatcher

Synopsis

Documentation

runIfDifferent :: (Object -> Handler r ()) -> Object -> Object -> Handler r () Source #

Run the handler if the two Objects are different.

checkVar :: Member (Rpc !! RpcError) r => WatchedVariable -> Object -> (Object -> Handler r ()) -> Handler r Object Source #

Fetch the current value of the watched variable and call the handler if its value has changed.

watchVariables :: Members [VariableWatcher !! Report, Rpc !! RpcError, Resource, Mask mres, Race, Embed IO] r => Map WatchedVariable (Object -> Handler r ()) -> Sem r a -> Sem r a Source #

This is a reactive system that is triggered by several frequently sent autocommands to inspect a user-defined set of Neovim variables for changes. When a variable's value has been observed to have changed from the previously recorded state, the associated handler is executed.

This handler has to be passed to runNvimPluginIO or similar as part of the custom effect stack, like:

runNvimPluginIO "my-plugin" (watchVariables [("variable_name", handler)]) mempty

This does not remove VariableWatcher from the stack, but intercepts and resends it, to make it simpler to use with the plugin runners.