Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Combinators for creating and manipulating RPC handlers.
Synopsis
- rpcFunction :: forall r h. HandlerCodec h r => RpcName -> Execution -> h -> RpcHandler r
- rpcCommand :: forall r h. HandlerCodec h r => CommandHandler OptionStateZero h => RpcName -> Execution -> h -> RpcHandler r
- complete :: CommandCompletion -> RpcHandler r -> RpcHandler r
- completeBuiltin :: Text -> RpcHandler r -> RpcHandler r
- completeCustom :: RpcName -> (Text -> Text -> Int -> Handler r [Text]) -> CompleteStyle -> RpcHandler r
- completeWith :: CompleteStyle -> (Text -> Text -> Int -> Handler r [Text]) -> RpcHandler r -> [RpcHandler r]
- rpcAutocmd :: forall r h. HandlerCodec h r => RpcName -> Execution -> AutocmdEvents -> AutocmdOptions -> h -> RpcHandler r
- rpc :: forall r h. HandlerCodec h r => CommandHandler OptionStateZero h => RpcName -> Execution -> h -> [RpcHandler r]
Documentation
:: forall r h. HandlerCodec h r | |
=> RpcName | Name of the Neovim function that will be created. |
-> Execution | Execute sync or async. |
-> h | The handler function. |
-> RpcHandler r |
Create an RpcHandler
that is triggered by a Neovim function of the specified name.
The handler can take arbitrary parameters, as long as they are instances of MsgpackDecode
(or more
specifically, HandlerArg
), just like the return type.
When invoking the function from Neovim, a value must be passed for each of the handler function's parameters, except
for some special cases, like a number of successive Maybe
parameters at the tail of the parameter list.
The function is converted to use messagepack types by the class HandlerCodec
.
For easier type inference, it is advisable to use
for the return type of the handler instead of using
Handler
r a
.Member
(Stop
LogReport
) r
Example:
import Ribosome ping :: Int -> Handler r Int ping 0 = basicLogReport "Invalid ping number!" ["This is written to the log"] ping i = pure i rpcFunction "Ping" Sync ping
:: forall r h. HandlerCodec h r | |
=> CommandHandler OptionStateZero h | |
=> RpcName | Name of the Neovim function that will be created. |
-> Execution | Execute sync or async. |
-> h | The handler function. |
-> RpcHandler r |
Create an RpcHandler
that is triggered by a Neovim command of the specified name.
The handler can take arbitrary parameters, as long as they are instances of MsgpackDecode
(or more
specifically, HandlerArg
), just like the return type.
The function is converted to use messagepack types by the class HandlerCodec
.
Commands have an (open) family of special parameter types that will be translated into command options, like
Range
for the line range specified to the command.
See command params.
For easier type inference, it is advisable to use
for the return type of the handler instead of using
Handler
r a
.Member
(Stop
Report
) r
complete :: CommandCompletion -> RpcHandler r -> RpcHandler r Source #
Add the given completion to an RpcHandler
.
completeBuiltin :: Text -> RpcHandler r -> RpcHandler r Source #
Configure the given RpcHandler
to use the specified builtin completion.
completeCustom :: RpcName -> (Text -> Text -> Int -> Handler r [Text]) -> CompleteStyle -> RpcHandler r Source #
completeWith :: CompleteStyle -> (Text -> Text -> Int -> Handler r [Text]) -> RpcHandler r -> [RpcHandler r] Source #
Add command line completion to another RpcHandler
by creating a new handler that calls the given function to
obtain possible completions.
:: forall r h. HandlerCodec h r | |
=> RpcName | |
-> Execution | Execute sync or async. While autocommands can not interact with return values, this is still useful to keep Neovim
from continuing execution while the handler is active, which is particularly important for |
-> AutocmdEvents | The Neovim event identifier, like |
-> AutocmdOptions | Various Neovim options like the file pattern. |
-> h | The handler function. |
-> RpcHandler r |
Create an RpcHandler
that is triggered by a Neovim autocommand for the specified event.
For a user autocommand, specify User
for the event and the event name for the file pattern in AutocmdOptions
.
For easier type inference, it is advisable to use
for the return type of the handler instead of using
Handler
r a
.Member
(Stop
Report
) r
rpc :: forall r h. HandlerCodec h r => CommandHandler OptionStateZero h => RpcName -> Execution -> h -> [RpcHandler r] Source #
Convenience function for creating a handler that is triggered by both a function and a command of the same name.
See rpcFunction
and rpcCommand
.