-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell plugin backend for neovim -- -- This package provides a plugin provider for neovim. It allows you to -- write plugins for one of the great editors of our time in the best -- programming language of our time! ;-) -- -- You should find all the documentation you need inside the -- Neovim module. All other modules are considered internal, so -- don't be annoyed if using things from there may break your code. -- -- If you spot any errors or if you have great ideas, feel free to open -- an issue on github. @package nvim-hs @version 0.0.1 module Neovim.Debug -- | Disable logging to stderr. disableLogger :: IO a -> IO a -- | Initialize the root logger to avoid stderr and set it to log the given -- file instead. Simply wrap the main entry point with this function to -- initialze the logger. main = withLogger -- "homedude/nvim.log" Debug $ do putStrLn "Hello, World!" withLogger :: FilePath -> Priority -> IO a -> IO a module Neovim.Plugin.IPC.Classes -- | Taken from xmonad and based on ideas in /An Extensible -- Dynamically-Typed Hierarchy of Exceptions/, Simon Marlow, 2006. -- -- User-extensible messages must be put into a value of this type, so -- that it can be sent to other plugins. data SomeMessage SomeMessage :: msg -> SomeMessage class Typeable message => Message message where fromMessage (SomeMessage message) = cast message fromMessage :: Message message => SomeMessage -> Maybe message module Neovim.Plugin.IPC.Internal -- | Haskell representation of supported Remote Procedure Call messages. data RPCMessage -- | Method name, parameters, callback, timestamp FunctionCall :: Text -> [Object] -> (TMVar (Either Object Object)) -> UTCTime -> RPCMessage -- | Response sent to indicate the result of a function call. -- -- Response :: !Int64 -> Object -> Object -> RPCMessage -- | Method name and parameters. NotificationCall :: Text -> [Object] -> RPCMessage -- | A request is a data type containing the method to call, its arguments -- and an identifier used to map the result to the function that has been -- called. data Request Request :: Text -> !Int64 -> [Object] -> Request -- | Name of the function to call. reqMethod :: Request -> Text -- | Identifier to map the result to a function call invocation. reqId :: Request -> !Int64 -- | Arguments for the function. reqArgs :: Request -> [Object] -- | A notification is similar to a Request. It essentially does the -- same thing, but the function is only called for its side effects. This -- type of message is sent by neovim if the caller there does not care -- about the result of the computation. data Notification Notification :: Text -> [Object] -> Notification -- | Name of the function to call. notMethod :: Notification -> Text -- | Argumentse for the function. notArgs :: Notification -> [Object] instance Typeable RPCMessage instance Typeable Request instance Typeable Notification instance Message Notification instance Message Request instance Message RPCMessage -- | This module reexports publicly available means to communicate between -- different plugins (or more generally threads running in the same -- plugin provider). module Neovim.Plugin.IPC -- | Taken from xmonad and based on ideas in /An Extensible -- Dynamically-Typed Hierarchy of Exceptions/, Simon Marlow, 2006. -- -- User-extensible messages must be put into a value of this type, so -- that it can be sent to other plugins. data SomeMessage SomeMessage :: msg -> SomeMessage -- | Try to convert a given message to a value of the message type we are -- interested in. Will evaluate to Nothing for any other type. fromMessage :: Message message => SomeMessage -> Maybe message module Neovim.Context -- | Retrieve something from the configuration with respect to the first -- function. Works exactly like asks. asks :: (r -> a) -> Neovim r st a -- | Retrieve the Cunfiguration (i.e. read-only state) from the -- Neovim context. ask :: Neovim r st r eventQueue :: Neovim r st (TQueue SomeMessage) 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 -- | 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 r st = StateT st (ReaderT (ConfigWrapper r) IO) -- | Convenience alias for Neovim () (). type Neovim' = Neovim () () data NeovimException ErrorMessage :: String -> NeovimException -- | A wrapper for a reader value that contains extra fields required to -- communicate with the messagepack-rpc components. data ConfigWrapper a ConfigWrapper :: TQueue SomeMessage -> MVar QuitAction -> String -> a -> ConfigWrapper a -- | A queue of messages that the event handler will propagate to -- appropriate threads and handlers. _eventQueue :: ConfigWrapper a -> TQueue SomeMessage -- | 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. _quit :: ConfigWrapper a -> MVar QuitAction -- | Name that is used to identify this provider. Assigning such a name is -- done in the neovim config (e.g. ~/.nvim/nvimrc). _providerName :: ConfigWrapper a -> String -- | Plugin author supplyable custom configuration. It can be queried via -- myConf. customConfig :: ConfigWrapper a -> a -- | Initialize a Neovim context by supplying an -- InternalEnvironment. runNeovim :: ConfigWrapper r -> st -> Neovim r st a -> IO (Either String (a, st)) -- | 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. forkNeovim :: ir -> ist -> Neovim ir ist a -> Neovim r st ThreadId -- |
--   throw . ErrorMessage
--   
err :: String -> Neovim r st a -- | Initiate a restart of the plugin provider. restart :: Neovim r st () -- | Initiate the termination of the plugin provider. quit :: Neovim r st () data QuitAction -- | Quit the plugin provider. Quit :: QuitAction -- | Restart the plugin provider. Restart :: QuitAction throwError :: MonadError e m => forall a. e -> m a instance Typeable NeovimException instance Show QuitAction instance Read QuitAction instance Eq QuitAction instance Ord QuitAction instance Enum QuitAction instance Bounded QuitAction instance Show NeovimException instance Exception NeovimException module Neovim.RPC.Common -- | 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 FunctionMap = Map Text FunctionType data FunctionType Stateless :: ([Object] -> Neovim' Object) -> FunctionType Stateful :: (TQueue SomeMessage) -> FunctionType -- | Things shared between the socket reader and the event handler. data RPCConfig RPCConfig :: TVar (Map Int64 (UTCTime, TMVar (Either Object Object))) -> TMVar FunctionMap -> RPCConfig -- | A map from message identifiers (as per RPC spec) to a tuple with a -- timestamp and a TMVar that is used to communicate the result -- back to the calling thread. recipients :: RPCConfig -> TVar (Map Int64 (UTCTime, TMVar (Either Object Object))) -- | A map that contains the function names which are registered to this -- plugin manager. Putting the map in a TMVar ensures that all -- functionality is registered properly before answering to requests send -- by neovim. functions :: RPCConfig -> TMVar FunctionMap -- | Create a new basic configuration containing a communication channel -- for remote procedure call events and an empty lookup table for -- functions to mediate. newRPCConfig :: (Applicative io, MonadIO io) => io RPCConfig -- | Simple data type defining the kind of socket the socket reader should -- use. data SocketType -- | Use the handle for receiving msgpack-rpc messages. This is suitable -- for an embedded neovim which is used in test cases. Stdout :: Handle -> SocketType -- | Read the connection information from the environment variable -- NVIM_LISTEN_ADDRESS. Environment :: SocketType -- | Use a unix socket. UnixSocket :: FilePath -> SocketType -- | Use an IP socket. First argument is the port and the second is the -- host name. TCP :: Int -> String -> SocketType -- | Create a Handle from the given socket description. -- -- The handle is not automatically closed. createHandle :: (Functor io, MonadIO io) => IOMode -> SocketType -> io Handle cleanUpHandle :: MonadIO io => Handle -> Bool -> io () module Neovim.Classes -- | Conversion from Object files to Haskell types and back with -- respect to neovim's interpretation. class NvimObject o where fromObjectUnsafe o = case fromObject o of { Left e -> error $ unwords ["Not the expected object:", show o, "(", e, ")"] Right obj -> obj } fromObject = return . fromObjectUnsafe toObject :: NvimObject o => o -> Object fromObjectUnsafe :: NvimObject o => Object -> o fromObject :: (NvimObject o, NvimObject o) => Object -> Either String o -- | A generic vim dictionary is a simply a map from strings to objects. -- This type alias is sometimes useful as a type annotation especially if -- the OverloadedStrings extension is enabled. type Dictionary = Map ByteString Object instance [overlap ok] NvimObject o => NvimObject (o, o, o, o, o, o, o, o, o) instance [overlap ok] NvimObject o => NvimObject (o, o, o, o, o, o, o, o) instance [overlap ok] NvimObject o => NvimObject (o, o, o, o, o, o, o) instance [overlap ok] NvimObject o => NvimObject (o, o, o, o, o, o) instance [overlap ok] NvimObject o => NvimObject (o, o, o, o, o) instance [overlap ok] NvimObject o => NvimObject (o, o, o, o) instance [overlap ok] NvimObject o => NvimObject (o, o, o) instance [overlap ok] NvimObject o => NvimObject (o, o) instance [overlap ok] NvimObject Object instance [overlap ok] NvimObject ByteString instance [overlap ok] NvimObject Text instance [overlap ok] (Ord key, NvimObject key, NvimObject val) => NvimObject (Map key val) instance [overlap ok] NvimObject o => NvimObject (Maybe o) instance [overlap ok] NvimObject o => NvimObject [o] instance [overlap ok] NvimObject [Char] instance [overlap ok] NvimObject Char instance [overlap ok] NvimObject Int instance [overlap ok] NvimObject Int16 instance [overlap ok] NvimObject Int32 instance [overlap ok] NvimObject Int64 instance [overlap ok] NvimObject Integer instance [overlap ok] NvimObject Double instance [overlap ok] NvimObject Bool instance [overlap ok] NvimObject () module Neovim.Plugin.Classes -- | This data type is used in the plugin registration to properly register -- the functions. newtype ExportedFunctionality r st EF :: (FunctionalityDescription, [Object] -> Neovim r st Object) -> ExportedFunctionality r st -- | Extract the function of an ExportedFunctionality. getFunction :: ExportedFunctionality r st -> [Object] -> Neovim r st Object -- | Extract the description of an ExportedFunctionality. getDescription :: ExportedFunctionality r st -> FunctionalityDescription -- | Functionality specific functional description entries. -- -- All fields which are directly specified in these constructors are not -- optional, but can partialy be generated via the Template Haskell -- functions. The last field is a data type that contains all relevant -- options with sensible defaults, hence def can be used as an -- argument. data FunctionalityDescription -- | Exported function. Callable via call name(arg1,arg2). -- -- Function :: Text -> Synchronous -> FunctionalityDescription -- | Exported Command. Callable via :Name arg1 arg2. -- -- Command :: Text -> CommandOptions -> FunctionalityDescription -- | Exported autocommand. Will call the given function if the type and -- filter match. -- -- NB: Since we are registering this on the Haskell side of things, the -- number of accepted arguments should be 0. TODO Should this be enforced -- somehow? Possibly via the TH generator. -- -- Autocmd :: Text -> Text -> AutocmdOptions -> FunctionalityDescription -- | Conveniennce class to extract a name from some value. class FunctionName a name :: FunctionName a => a -> Text data NeovimPlugin NeovimPlugin :: (Plugin r st) -> NeovimPlugin -- | This data type contains meta information for the plugin manager. data Plugin r st Plugin :: [ExportedFunctionality () ()] -> [(r, st, [ExportedFunctionality r st])] -> Plugin r st exports :: Plugin r st -> [ExportedFunctionality () ()] statefulExports :: Plugin r st -> [(r, st, [ExportedFunctionality r st])] -- | Wrap a Plugin in some nice blankets, so that we can put them in -- a simple list. wrapPlugin :: Monad m => Plugin r st -> m NeovimPlugin -- | This option detemines how neovim should behave when calling some -- functionality on a remote host. data Synchronous -- | Call the functionality entirely for its side effects and do not wait -- for it to finish. Calling a functionality with this flag set is -- completely asynchronous and nothing is really expected to happen. This -- is why a call like this is called notification on the neovim side of -- things. Async :: Synchronous -- | Call the function and wait for its result. This is only synchronous on -- the neovim side. For comands it means that the GUI will (probably) not -- allow any user input until a reult is received. Functions run -- asynchronously inside neovim (or in one of its plugin providers) can -- use these functions concurrently. Sync :: Synchronous -- | Options that can be optionally set for commands. -- -- TODO Determine which of these make sense, how they are transmitted -- back and which options are still missing. (see remoteCommandOnHost in -- runtime/autoload/remote/define.vim)) data CommandOptions CommandOptions :: Synchronous -> Maybe Text -> Bool -> Int -> Bool -> CommandOptions -- | Option to indicate whether vim shuould block until the command has -- completed. (default: Sync) cmdSync :: CommandOptions -> Synchronous -- | Vim expression for the range (or count). (default: "") cmdRange :: CommandOptions -> Maybe Text -- | If true, cmdCount :: CommandOptions -> Bool -- | Number of arguments. Note that all arguments have to be a string type. -- -- TODO Check this in the Template Haskell functions. -- -- If you're using the template haskell functions for registering -- commands, this field is overridden by it. cmdNargs :: CommandOptions -> Int -- | Behavior changes when using a bang. cmdBang :: CommandOptions -> Bool data AutocmdOptions AutocmdOptions :: Synchronous -> Text -> Bool -> AutocmdOptions -- | Option to indicate whether vim shuould block until the function has -- completed. (default: Sync) acmdSync :: AutocmdOptions -> Synchronous -- | Pattern to match on. (default: "*") acmdPattern :: AutocmdOptions -> Text -- | Nested autocmd. (default: False) -- -- See :h autocmd-nested acmdNested :: AutocmdOptions -> Bool instance Show Synchronous instance Read Synchronous instance Eq Synchronous instance Ord Synchronous instance Enum Synchronous instance Show CommandOptions instance Read CommandOptions instance Eq CommandOptions instance Ord CommandOptions instance Show AutocmdOptions instance Read AutocmdOptions instance Eq AutocmdOptions instance Ord AutocmdOptions instance Show FunctionalityDescription instance Read FunctionalityDescription instance Eq FunctionalityDescription instance Ord FunctionalityDescription instance FunctionName (ExportedFunctionality r st) instance FunctionName FunctionalityDescription instance NvimObject AutocmdOptions instance Default AutocmdOptions instance NvimObject CommandOptions instance Default CommandOptions instance NvimObject Synchronous instance Default Synchronous module Neovim.Config data NeovimConfig Config :: [IO NeovimPlugin] -> Maybe String -> Maybe (FilePath, Priority) -> Maybe (Params NeovimConfig) -> NeovimConfig -- | The list of plugins. The IO type inside the list allows the plugin -- author to run some arbitrary startup code before creating a value of -- type NeovimPlugin. plugins :: NeovimConfig -> [IO NeovimPlugin] -- | Used by Dyre for storing compilation errors. errorMessage :: NeovimConfig -> Maybe String -- | Set the general logging options. logOptions :: NeovimConfig -> Maybe (FilePath, Priority) -- | Parmaeters used by Dyre. This is only used for the -- Neovim.Plugin.ConfigHelper plugin. dyreParams :: NeovimConfig -> Maybe (Params NeovimConfig) instance Default NeovimConfig module Neovim.RPC.FunctionCall -- | Helper function that concurrently puts a Message in the event -- queue and returns an STM action that returns the result. acall :: NvimObject result => Text -> [Object] -> Neovim r st (STM (Either Object result)) acall' :: NvimObject result => Text -> [Object] -> Neovim r st (STM result) -- | Call a neovim function synchronously. This function blocks until the -- result is available. scall :: NvimObject result => Text -> [Object] -> Neovim r st (Either Object result) scall' :: NvimObject result => Text -> [Object] -> Neovim r st result -- | Lifted variant of atomically. atomically' :: MonadIO io => STM result -> io result -- | Wait for the result of the STM action. -- -- This action possibly blocks as it is an alias for ioSTM -> -- ioSTM >>= liftIO . atomically. wait :: Neovim r st (STM result) -> Neovim r st result -- | Variant of wait that discards the result. wait' :: Neovim r st (STM result) -> Neovim r st () -- | Wait for the result of the STM action and call err . -- (loc++) . show if the action returned an error. waitErr :: Show e => String -> Neovim r st (STM (Either e result)) -> Neovim r st result -- | waitErr that discards the result. waitErr' :: Show e => String -> Neovim r st (STM (Either e result)) -> Neovim r st () -- | Send the result back to the neovim instance. respond :: NvimObject result => Request -> Either String result -> Neovim r st () module Neovim.RPC.EventHandler -- | This function will establish a connection to the given socket and -- write msgpack-rpc requests to it. runEventHandler :: SocketType -> ConfigWrapper RPCConfig -> IO () instance Functor EventHandler instance Applicative EventHandler instance Monad EventHandler instance MonadState Int64 EventHandler instance MonadIO EventHandler instance MonadReader (ConfigWrapper RPCConfig) EventHandler module Neovim.RPC.SocketReader -- | This function will establish a connection to the given socket and read -- msgpack-rpc events from it. runSocketReader :: SocketType -> ConfigWrapper RPCConfig -> IO () instance Functor SocketHandler instance Applicative SocketHandler instance Monad SocketHandler instance MonadIO SocketHandler instance MonadReader (ConfigWrapper RPCConfig) SocketHandler instance MonadThrow SocketHandler module Neovim.API.String data NeovimExceptionGen NeovimException :: !ByteString -> NeovimExceptionGen NeovimValidation :: !ByteString -> NeovimExceptionGen data Buffer Buffer :: !ByteString -> Buffer data Tabpage Tabpage :: !ByteString -> Tabpage data Window Window :: !ByteString -> Window window_is_valid :: Window -> forall r st. Neovim r st Bool window_get_tabpage :: Window -> forall r st. Neovim r st (Either Object Tabpage) window_get_position :: Window -> forall r st. Neovim r st (Either Object (Int64, Int64)) window_set_option :: Window -> String -> Object -> forall r st. Neovim r st (STM (Either Object ())) window_get_option :: Window -> String -> forall r st. Neovim r st (Either Object Object) window_set_var :: Window -> String -> Object -> forall r st. Neovim r st (STM (Either Object Object)) window_get_var :: Window -> String -> forall r st. Neovim r st (Either Object Object) window_set_width :: Window -> Int64 -> forall r st. Neovim r st (STM (Either Object ())) window_get_width :: Window -> forall r st. Neovim r st (Either Object Int64) window_set_height :: Window -> Int64 -> forall r st. Neovim r st (STM (Either Object ())) window_get_height :: Window -> forall r st. Neovim r st (Either Object Int64) window_set_cursor :: Window -> (Int64, Int64) -> forall r st. Neovim r st (STM (Either Object ())) window_get_cursor :: Window -> forall r st. Neovim r st (Either Object (Int64, Int64)) window_get_buffer :: Window -> forall r st. Neovim r st (Either Object Buffer) buffer_get_mark :: Buffer -> String -> forall r st. Neovim r st (Either Object (Int64, Int64)) buffer_insert :: Buffer -> Int64 -> [String] -> forall r st. Neovim r st (STM (Either Object ())) buffer_is_valid :: Buffer -> forall r st. Neovim r st Bool buffer_set_name :: Buffer -> String -> forall r st. Neovim r st (STM (Either Object ())) buffer_get_name :: Buffer -> forall r st. Neovim r st (Either Object String) buffer_get_number :: Buffer -> forall r st. Neovim r st (Either Object Int64) buffer_set_option :: Buffer -> String -> Object -> forall r st. Neovim r st (STM (Either Object ())) buffer_get_option :: Buffer -> String -> forall r st. Neovim r st (Either Object Object) buffer_set_var :: Buffer -> String -> Object -> forall r st. Neovim r st (STM (Either Object Object)) buffer_get_var :: Buffer -> String -> forall r st. Neovim r st (Either Object Object) buffer_set_line_slice :: Buffer -> Int64 -> Int64 -> Bool -> Bool -> [String] -> forall r st. Neovim r st (STM (Either Object ())) buffer_get_line_slice :: Buffer -> Int64 -> Int64 -> Bool -> Bool -> forall r st. Neovim r st (Either Object [String]) buffer_del_line :: Buffer -> Int64 -> forall r st. Neovim r st (STM (Either Object ())) buffer_set_line :: Buffer -> Int64 -> String -> forall r st. Neovim r st (STM (Either Object ())) buffer_get_line :: Buffer -> Int64 -> forall r st. Neovim r st (Either Object String) buffer_line_count :: Buffer -> forall r st. Neovim r st (Either Object Int64) vim_get_api_info :: Neovim r st [Object] vim_get_color_map :: Neovim r st (Map Object Object) vim_name_to_color :: String -> forall r st. Neovim r st Int64 vim_unsubscribe :: String -> forall r st. Neovim r st () vim_subscribe :: String -> forall r st. Neovim r st () vim_set_current_tabpage :: Tabpage -> forall r st. Neovim r st (STM (Either Object ())) vim_get_current_tabpage :: Neovim r st Tabpage vim_get_tabpages :: Neovim r st [Tabpage] vim_set_current_window :: Window -> forall r st. Neovim r st (STM (Either Object ())) vim_get_current_window :: Neovim r st Window vim_get_windows :: Neovim r st [Window] vim_set_current_buffer :: Buffer -> forall r st. Neovim r st (STM (Either Object ())) vim_get_current_buffer :: Neovim r st Buffer vim_get_buffers :: Neovim r st [Buffer] vim_report_error :: String -> forall r st. Neovim r st (STM ()) vim_err_write :: String -> forall r st. Neovim r st (STM ()) vim_out_write :: String -> forall r st. Neovim r st (STM ()) vim_set_option :: String -> Object -> forall r st. Neovim r st (STM (Either Object ())) vim_get_option :: String -> forall r st. Neovim r st (Either Object Object) vim_get_vvar :: String -> forall r st. Neovim r st (Either Object Object) vim_set_var :: String -> Object -> forall r st. Neovim r st (STM (Either Object Object)) vim_get_var :: String -> forall r st. Neovim r st (Either Object Object) vim_del_current_line :: Neovim r st (STM (Either Object ())) vim_set_current_line :: String -> forall r st. Neovim r st (STM (Either Object ())) vim_get_current_line :: Neovim r st (Either Object String) vim_change_directory :: String -> forall r st. Neovim r st (Either Object ()) vim_list_runtime_paths :: Neovim r st [String] vim_strwidth :: String -> forall r st. Neovim r st (Either Object Int64) vim_call_dict_function :: Object -> Bool -> String -> [Object] -> forall r st. Neovim r st (STM (Either Object Object)) vim_call_function :: String -> [Object] -> forall r st. Neovim r st (STM (Either Object Object)) vim_eval :: String -> forall r st. Neovim r st (STM (Either Object Object)) vim_command_output :: String -> forall r st. Neovim r st (Either Object String) vim_replace_termcodes :: String -> Bool -> Bool -> Bool -> forall r st. Neovim r st String vim_input :: String -> forall r st. Neovim r st Int64 vim_feedkeys :: String -> String -> Bool -> forall r st. Neovim r st (STM ()) vim_command :: String -> forall r st. Neovim r st (STM (Either Object ())) tabpage_is_valid :: Tabpage -> forall r st. Neovim r st Bool tabpage_get_window :: Tabpage -> forall r st. Neovim r st (Either Object Window) tabpage_set_var :: Tabpage -> String -> Object -> forall r st. Neovim r st (STM (Either Object Object)) tabpage_get_var :: Tabpage -> String -> forall r st. Neovim r st (Either Object Object) tabpage_get_windows :: Tabpage -> forall r st. Neovim r st (Either Object [Window]) instance Typeable NeovimExceptionGen instance Typeable Buffer instance Typeable Tabpage instance Typeable Window instance Eq NeovimExceptionGen instance Show NeovimExceptionGen instance Eq Buffer instance Show Buffer instance Eq Tabpage instance Show Tabpage instance Eq Window instance Show Window instance NvimObject Window instance NvimObject Tabpage instance NvimObject Buffer instance NvimObject NeovimExceptionGen instance Exception NeovimExceptionGen module Neovim.Plugin startPluginThreads :: ConfigWrapper r -> [IO NeovimPlugin] -> IO (Either String [(NeovimPlugin, [(ThreadId, [(FunctionalityDescription, FunctionType)])])]) register :: ConfigWrapper (TMVar FunctionMap) -> [(NeovimPlugin, [(ThreadId, [(FunctionalityDescription, FunctionType)])])] -> IO () -- | Wrap a Plugin in some nice blankets, so that we can put them in -- a simple list. wrapPlugin :: Monad m => Plugin r st -> m NeovimPlugin data NeovimPlugin -- | This data type contains meta information for the plugin manager. data Plugin r st Plugin :: [ExportedFunctionality () ()] -> [(r, st, [ExportedFunctionality r st])] -> Plugin r st exports :: Plugin r st -> [ExportedFunctionality () ()] statefulExports :: Plugin r st -> [(r, st, [ExportedFunctionality r st])] -- | This option detemines how neovim should behave when calling some -- functionality on a remote host. data Synchronous -- | Call the functionality entirely for its side effects and do not wait -- for it to finish. Calling a functionality with this flag set is -- completely asynchronous and nothing is really expected to happen. This -- is why a call like this is called notification on the neovim side of -- things. Async :: Synchronous -- | Call the function and wait for its result. This is only synchronous on -- the neovim side. For comands it means that the GUI will (probably) not -- allow any user input until a reult is received. Functions run -- asynchronously inside neovim (or in one of its plugin providers) can -- use these functions concurrently. Sync :: Synchronous -- | Options that can be optionally set for commands. -- -- TODO Determine which of these make sense, how they are transmitted -- back and which options are still missing. (see remoteCommandOnHost in -- runtime/autoload/remote/define.vim)) data CommandOptions CommandOptions :: Synchronous -> Maybe Text -> Bool -> Int -> Bool -> CommandOptions -- | Option to indicate whether vim shuould block until the command has -- completed. (default: Sync) cmdSync :: CommandOptions -> Synchronous -- | Vim expression for the range (or count). (default: "") cmdRange :: CommandOptions -> Maybe Text -- | If true, cmdCount :: CommandOptions -> Bool -- | Number of arguments. Note that all arguments have to be a string type. -- -- TODO Check this in the Template Haskell functions. -- -- If you're using the template haskell functions for registering -- commands, this field is overridden by it. cmdNargs :: CommandOptions -> Int -- | Behavior changes when using a bang. cmdBang :: CommandOptions -> Bool module Neovim.Quickfix setqflist :: (Monoid strType, NvimObject strType) => [QuickfixListItem strType] -> QuickfixAction -> Neovim r st () -- | Quickfix list item. The parameter names should mostly conform to those -- in :h setqflist(). Some fields are merged to explicitly state -- mutually exclusive elements or some other behavior of the fields. -- -- see quickfixListItem for creating a value of this type without -- typing too much. data QuickfixListItem strType QFItem :: Either Int strType -> Either Int strType -> Maybe (Int, Bool) -> Maybe Int -> strType -> strType -> QuickfixListItem strType -- | Since the filename is only used if no buffer can be specified, this -- field is a merge of bufnr and filename. bufOrFile :: QuickfixListItem strType -> Either Int strType -- | Line number or search pattern to locate the error. lnumOrPattern :: QuickfixListItem strType -> Either Int strType -- | A tuple of a column number and a boolean indicating which kind of -- indexing should be used. True means that the visual column -- should be used. False means to use the byte index. col :: QuickfixListItem strType -> Maybe (Int, Bool) -- | Error number. nr :: QuickfixListItem strType -> Maybe Int -- | Description of the error. text :: QuickfixListItem strType -> strType -- | TODO replace with enum, but too lazy for now. errorType :: QuickfixListItem strType -> strType -- | Create a QuickfixListItem by providing the minimal amount of -- arguments needed. quickfixListItem :: Monoid strType => Either Int strType -> Either Int strType -> QuickfixListItem strType data QuickfixAction -- | Add items to the current list (or create a new one if none exists). Append :: QuickfixAction -- | Replace current list (or create a new one if none exists). Replace :: QuickfixAction -- | Create a new list. New :: QuickfixAction instance Eq strType => Eq (QuickfixListItem strType) instance Show strType => Show (QuickfixListItem strType) instance Eq QuickfixAction instance Ord QuickfixAction instance Enum QuickfixAction instance Bounded QuickfixAction instance Show QuickfixAction instance NvimObject QuickfixAction instance (Monoid strType, NvimObject strType) => NvimObject (QuickfixListItem strType) module Neovim.Plugin.ConfigHelper -- | Note that you cannot really use this plugin by hand. It is -- automatically loaded for all Neovim instances. plugin :: Params NeovimConfig -> IO NeovimPlugin module Neovim.Main data CommandLineOptions Opt :: String -> Maybe (String, Int) -> Maybe FilePath -> Bool -> Maybe (FilePath, Priority) -> CommandLineOptions providerName :: CommandLineOptions -> String hostPort :: CommandLineOptions -> Maybe (String, Int) unix :: CommandLineOptions -> Maybe FilePath env :: CommandLineOptions -> Bool logOpts :: CommandLineOptions -> Maybe (FilePath, Priority) optParser :: Parser CommandLineOptions opts :: ParserInfo CommandLineOptions -- | This is essentially the main function for nvim-hs, at least if -- you want to use the Config.Dyre for the configuration.. neovim :: NeovimConfig -> IO () realMain :: NeovimConfig -> IO () runPluginProvider :: CommandLineOptions -> NeovimConfig -> IO () finish :: [ThreadId] -> QuitAction -> IO () -- | This module should contain all the things you need to write neovim -- plugins in your favorite language! :-) -- -- The documentation in this module should enable you to write plugins. -- The chapters in this module start with a tl;dr paragraph that sums -- things up, which is useful to get an idea whether you should actually -- read the chapter and which will reduce your reading time if you just -- want to refresh your memory. module Neovim -- | 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 r st = StateT st (ReaderT (ConfigWrapper r) IO) -- | Convenience alias for Neovim () (). type Neovim' = Neovim () () -- | This is essentially the main function for nvim-hs, at least if -- you want to use the Config.Dyre for the configuration.. neovim :: NeovimConfig -> IO () data NeovimConfig Config :: [IO NeovimPlugin] -> Maybe String -> Maybe (FilePath, Priority) -> Maybe (Params NeovimConfig) -> NeovimConfig -- | The list of plugins. The IO type inside the list allows the plugin -- author to run some arbitrary startup code before creating a value of -- type NeovimPlugin. plugins :: NeovimConfig -> [IO NeovimPlugin] -- | Used by Dyre for storing compilation errors. errorMessage :: NeovimConfig -> Maybe String -- | Set the general logging options. logOptions :: NeovimConfig -> Maybe (FilePath, Priority) -- | Parmaeters used by Dyre. This is only used for the -- Neovim.Plugin.ConfigHelper plugin. dyreParams :: NeovimConfig -> Maybe (Params NeovimConfig) def :: Default a => a data NeovimPlugin NeovimPlugin :: (Plugin r st) -> NeovimPlugin -- | This data type contains meta information for the plugin manager. data Plugin r st Plugin :: [ExportedFunctionality () ()] -> [(r, st, [ExportedFunctionality r st])] -> Plugin r st exports :: Plugin r st -> [ExportedFunctionality () ()] statefulExports :: Plugin r st -> [(r, st, [ExportedFunctionality r st])] -- | Conversion from Object files to Haskell types and back with -- respect to neovim's interpretation. class NvimObject o where fromObjectUnsafe o = case fromObject o of { Left e -> error $ unwords ["Not the expected object:", show o, "(", e, ")"] Right obj -> obj } fromObject = return . fromObjectUnsafe toObject :: NvimObject o => o -> Object fromObject :: (NvimObject o, NvimObject o) => Object -> Either String o -- | A generic vim dictionary is a simply a map from strings to objects. -- This type alias is sometimes useful as a type annotation especially if -- the OverloadedStrings extension is enabled. type Dictionary = Map ByteString Object data Object :: * ObjectNil :: Object ObjectInt :: Int64 -> Object ObjectBool :: Bool -> Object ObjectFloat :: Float -> Object ObjectDouble :: Double -> Object ObjectString :: ByteString -> Object ObjectBinary :: ByteString -> Object ObjectArray :: [Object] -> Object ObjectMap :: Map Object Object -> Object ObjectExt :: UnpkInt8 -> ByteString -> Object -- | Wrap a Plugin in some nice blankets, so that we can put them in -- a simple list. wrapPlugin :: Monad m => Plugin r st -> m NeovimPlugin -- | Define an exported function by providing a cutom name and referencing -- the function you want to export. -- -- Note that the name must start with an upper case letter. -- -- Example: $(function MyExportedFunction 'myDefinedFunction) -- def function :: String -> Name -> Q Exp -- | Define an exported function. This function works exactly like -- function, but it generates the exported name automatically by -- converting the first letter to upper case. function' :: Name -> Q Exp -- | Similarly to function, this function is used to export a -- command with a custom name. -- -- Note that commands must start with an upper case letter. command :: String -> Name -> Q Exp -- | Define an exported command. This function works exactly like -- command, but it generates the command name by converting the -- first letter to upper case. command' :: Name -> Q Exp -- | Define an autocmd. This function generates an export for autocmd. -- Since this is a static registration, arguments are not allowed here. -- You can of course define a fully applied functions and pass it as an -- arguments. autocmd :: Name -> Q Exp -- | This option detemines how neovim should behave when calling some -- functionality on a remote host. data Synchronous -- | Call the functionality entirely for its side effects and do not wait -- for it to finish. Calling a functionality with this flag set is -- completely asynchronous and nothing is really expected to happen. This -- is why a call like this is called notification on the neovim side of -- things. Async :: Synchronous -- | Call the function and wait for its result. This is only synchronous on -- the neovim side. For comands it means that the GUI will (probably) not -- allow any user input until a reult is received. Functions run -- asynchronously inside neovim (or in one of its plugin providers) can -- use these functions concurrently. Sync :: Synchronous -- | Options that can be optionally set for commands. -- -- TODO Determine which of these make sense, how they are transmitted -- back and which options are still missing. (see remoteCommandOnHost in -- runtime/autoload/remote/define.vim)) data CommandOptions CommandOptions :: Synchronous -> Maybe Text -> Bool -> Int -> Bool -> CommandOptions -- | Option to indicate whether vim shuould block until the command has -- completed. (default: Sync) cmdSync :: CommandOptions -> Synchronous -- | Vim expression for the range (or count). (default: "") cmdRange :: CommandOptions -> Maybe Text -- | If true, cmdCount :: CommandOptions -> Bool -- | Number of arguments. Note that all arguments have to be a string type. -- -- TODO Check this in the Template Haskell functions. -- -- If you're using the template haskell functions for registering -- commands, this field is overridden by it. cmdNargs :: CommandOptions -> Int -- | Behavior changes when using a bang. cmdBang :: CommandOptions -> Bool data AutocmdOptions AutocmdOptions :: Synchronous -> Text -> Bool -> AutocmdOptions -- | Option to indicate whether vim shuould block until the function has -- completed. (default: Sync) acmdSync :: AutocmdOptions -> Synchronous -- | Pattern to match on. (default: "*") acmdPattern :: AutocmdOptions -> Text -- | Nested autocmd. (default: False) -- -- See :h autocmd-nested acmdNested :: AutocmdOptions -> Bool -- | Retrieve the Cunfiguration (i.e. read-only state) from the -- Neovim context. ask :: Neovim r st r -- | Retrieve something from the configuration with respect to the first -- function. Works exactly like asks. asks :: (r -> a) -> Neovim r st a put :: MonadState s m => s -> m () get :: MonadState s m => m s gets :: MonadState s m => (s -> a) -> m a modify :: MonadState s m => (s -> s) -> m () -- | Wait for the result of the STM action. -- -- This action possibly blocks as it is an alias for ioSTM -> -- ioSTM >>= liftIO . atomically. wait :: Neovim r st (STM result) -> Neovim r st result -- | Variant of wait that discards the result. wait' :: Neovim r st (STM result) -> Neovim r st () -- | Wait for the result of the STM action and call err . -- (loc++) . show if the action returned an error. waitErr :: Show e => String -> Neovim r st (STM (Either e result)) -> Neovim r st result -- | waitErr that discards the result. waitErr' :: Show e => String -> Neovim r st (STM (Either e result)) -> Neovim r st () -- |
--   throw . ErrorMessage
--   
err :: String -> Neovim r st a liftIO :: MonadIO m => forall a. IO a -> m a