package vcaml
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d30d1858696f21cb2863ff1a3c39fc9b12c488aa5328073e300ec852d2716a1e
md5=f667331f1f877114bbfdaaf078159581
doc/vcaml/Vcaml/index.html
Module Vcaml
Source
Client_info is present for every remote, ui, embedder, host, or plugin attached to neovim.
A 'a api_call
is a thunked call to neovim returning a Msgpack-encoded 'a
. No RPC traffic is generated until an api_call
is invoked via run
or run_join
.
api_call
's can be manipulated with an applicative-like interface.
A good mental model is that invoking a 'a api_call
should cause exactly one RPC message to be sent to the neovim client, and that any operations within will not be interrupted. Calls with side effects will occur in the order written, so
let%map _a = a
and _b = b
in
()
will cause neovim to first run a
and then b
.
This is important for applications that rely on manipulating neovim's internal state. In particular, the atomicity guarantee prevents races with other pending operations, including user input.
You can run an Api_call.t
with run
or run_join
.
val wrap_viml_function :
type_:('fn, 'leftmost, 'out) Defun.Vim.t ->
function_name:string ->
'fn
Given the name of a function available in vimscript (VimL) along with its arity (see Defun.Vim
), return a regularly-typed OCaml function that calls said function.
This is intended for client authors to delegate work back to neovim, possibly to call an existing vimscript function. Before reaching for this function, please check the functions available in Neovim
, Buf
, Window
and Tabpage
to see that the functionality you intend to wrap isn't directly exposed in the API.
val register_request_blocking :
Client.t ->
name:string ->
type_:('fn, 'leftmost) Defun.Ocaml.Sync.t ->
f:'fn ->
unit Core.Or_error.t
Register a function callable from neovim. Note that this does not define the function in vimL itself, but instead adds a listener to the neovim msgpack_rpc bus. Such functions can be invoked from neovim via rpcrequest
or rpcnotify
along the correct channel. This is so that library wrappers can choose how to implement the actual vimL functions as needed.
A synchronous request sends a request to the OCaml program, and then blocks on receiving a response. This can cause deadlocks if said request itself attempts to perform neovim operations, so synchronous functions should run as quickly as possible without binding on any Deferred
s. This is enforced by the definition of Defun.Sync.Type
.
Asynchronous requests cannot directly return values to neovim, but do not block neovim while running. This can be used to indirectly update neovim by, for example, calling another neovim function within the handler (which can itself send another async request, etc).
val register_request_async :
Client.t ->
name:string ->
type_:'fn Defun.Ocaml.Async.t ->
f:'fn ->
unit