package vcaml

  1. Overview
  2. Docs
module Internal = Nvim_internal
module Client_info : sig ... end

Client_info is present for every remote, ui, embedder, host, or plugin attached to neovim.

module Channel_info : sig ... end
module Nvim_command : sig ... end
module Keymap : sig ... end

A representation of a keybinding

module Buf : sig ... end
module Window : sig ... end
module Tabpage : sig ... end
module Client : sig ... end
module Type : sig ... end

A Type.t is a reified values of a primitive type used in nvim.

type 'a api_call = 'a Api_call.t

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.

module Api_call : sig ... end
module Property : sig ... end

Contains a getter and setter for a given variable or property.

module Defun : sig ... end
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 wrap_var : name:string -> type_:'a Type.t -> 'a Property.t
val wrap_option : name:string -> type_:'a Type.t -> 'a Property.t
val wrap_get_vvar : name:string -> type_:'a Type.t -> 'a Core.Or_error.t api_call
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 Deferreds. 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
val convert_msgpack_response : 'a Type.t -> Msgpack.t Core.Or_error.t api_call -> 'a Core.Or_error.t api_call
OCaml

Innovation. Community. Security.