Module Vcaml
module Internal = Nvim_internalmodule Client_info : sig ... endmodule Channel_info : sig ... endmodule Nvim_command : sig ... endmodule Keymap : sig ... endmodule Buf : sig ... endmodule Window : sig ... endmodule Tabpage : sig ... endmodule Client : sig ... endmodule Type : sig ... endA
Type.tis a reified values of a primitive type used in nvim.
type 'a api_call= 'a Api_call.tA
'a api_callis a thunked call to neovim returning a Msgpack-encoded'a. No RPC traffic is generated until anapi_callis invoked viarunorrun_join.api_call's can be manipulated with an applicative-like interface.A good mental model is that invoking a
'a api_callshould 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, solet%map _a = a and _b = b in ()will cause neovim to first run
aand thenb.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.twithrunorrun_join.
module Api_call : sig ... endval run : Client.t -> 'a api_call -> 'a Core.Or_error.t Async.Deferred.tval run_join : Client.t -> 'a Core.Or_error.t api_call -> 'a Core.Or_error.t Async.Deferred.t
module Property : sig ... endContains a getter and setter for a given variable or property.
module Defun : sig ... endval wrap_viml_function : type_:('fn, 'leftmost, 'out) Defun.Vim.t -> function_name:string -> 'fnGiven 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,WindowandTabpageto see that the functionality you intend to wrap isn't directly exposed in the API.
val wrap_var : name:string -> type_:'a Type.t -> 'a Property.tval wrap_option : name:string -> type_:'a Type.t -> 'a Property.tval wrap_get_vvar : name:string -> type_:'a Type.t -> 'a Core.Or_error.t api_callval register_request_blocking : Client.t -> name:string -> type_:('fn, 'leftmost) Defun.Ocaml.Sync.t -> f:'fn -> unit Core.Or_error.tRegister 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
rpcrequestorrpcnotifyalong 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
Deferreds. This is enforced by the definition ofDefun.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 -> unitval convert_msgpack_response : 'a Type.t -> Msgpack.t Core.Or_error.t api_call -> 'a Core.Or_error.t api_call