package vcaml

  1. Overview
  2. Docs
OCaml bindings for the Neovim API

Install

Dune Dependency

Authors

Maintainers

Sources

vcaml-v0.14.0.tar.gz
sha256=d30d1858696f21cb2863ff1a3c39fc9b12c488aa5328073e300ec852d2716a1e
md5=f667331f1f877114bbfdaaf078159581

doc/vcaml/Vcaml/index.html

Module VcamlSource

Sourcemodule Internal = Nvim_internal
Sourcemodule Client_info : sig ... end

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

Sourcemodule Channel_info : sig ... end
Sourcemodule Nvim_command : sig ... end
Sourcemodule Keymap : sig ... end

A representation of a keybinding

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

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

Sourcetype '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.

Sourcemodule Api_call : sig ... end
Sourceval run : Client.t -> 'a api_call -> 'a Core.Or_error.t Async.Deferred.t
Sourceval run_join : Client.t -> 'a Core.Or_error.t api_call -> 'a Core.Or_error.t Async.Deferred.t
Sourcemodule Property : sig ... end

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

Sourcemodule Defun : sig ... end
Sourceval 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.

Sourceval wrap_var : name:string -> type_:'a Type.t -> 'a Property.t
Sourceval wrap_option : name:string -> type_:'a Type.t -> 'a Property.t
Sourceval wrap_get_vvar : name:string -> type_:'a Type.t -> 'a Core.Or_error.t api_call
Sourceval 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).

Sourceval register_request_async : Client.t -> name:string -> type_:'fn Defun.Ocaml.Async.t -> f:'fn -> unit
Sourceval 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.