module Neovim.Plugin.Internal (
ExportedFunctionality(..),
StatefulFunctionality(..),
getFunction,
getDescription,
NeovimPlugin(..),
Plugin(..),
wrapPlugin,
) where
import Neovim.Context
import Neovim.Plugin.Classes
import Data.MessagePack
newtype ExportedFunctionality r st
= EF (FunctionalityDescription, [Object] -> Neovim r st Object)
getDescription :: ExportedFunctionality r st -> FunctionalityDescription
getDescription (EF (d,_)) = d
getFunction :: ExportedFunctionality r st -> [Object] -> Neovim r st Object
getFunction (EF (_, f)) = f
instance HasFunctionName (ExportedFunctionality r st) where
name = name . getDescription
data StatefulFunctionality r st = StatefulFunctionality
{ readOnly :: r
, writable :: st
, functionalities :: [ExportedFunctionality r st]
}
data Plugin r st = Plugin
{ exports :: [ExportedFunctionality () ()]
, statefulExports :: [StatefulFunctionality r st]
}
data NeovimPlugin = forall r st. NeovimPlugin (Plugin r st)
wrapPlugin :: Applicative m => Plugin r st -> m NeovimPlugin
wrapPlugin = pure . NeovimPlugin