package vcaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

A value of type Connection_type.t describes the type of connection to use, along with the information necessary to connect to Neovim.

With a Unix connection, the plugin communicates with Neovim over the unix domain socket it uses to serve RPC requests. Unix `Child should be used if the plugin is launched from within Neovim; if it is launched independently a path to the socket will need to be provided.

With a Stdio connection, the plugin communicates with Neovim using its own stdin and stdout (which means stdout cannot be used for logging). This connection type should only be used if the plugin is launched from Neovim with jobstart with rpc:1 in opts.

Stdio connections are useful for synchronous, "one-shot" plugins where you want to synchronously start the process, communicate with Neovim, and shut down. To make this work, after starting the plugin, issue an rpcrequest, which will cause Neovim to block. The plugin should register the requested RPC before connecting to Neovim to ensure the RPC is defined at the time Neovim's request is handled. After handling the request, the plugin should shut down. If you tried to do this with a Unix connection then after the process is launched you would need to create a new channel but Neovim can't do that while in the middle of processing whatever logic it's currently executing that launched the process. To achieve synchronicity in this way you'd need a continuation - after launching the process you'd need to yield to the event loop so the channel could be established, and then the plugin would need to invoke a callback in Neovim to continue.

The Embed connection is the inverse of the Stdio connection - instead of the OCaml app being launched by Neovim, Neovim is launched by the OCaml app. Just as in a Stdio connection the app's stdin and stdout are used for RPC communication, here Neovim's stdin and stdout are used to communicate with the embedding process. Embed is most useful for testing and for graphical applications that want to embed Neovim for editing text. When Embed is used the --embed flag must be passed in args.

type _ t =
  1. | Unix : [ `Child | `Socket of string ] -> [ `connected ] Client.t t
  2. | Stdio : [ `connected ] Client.t t
  3. | Embed : {
    1. prog : string;
    2. args : string list;
    3. working_dir : string;
    4. env : Core_unix.env;
    } -> ([ `connected ] Client.t * Async.Process.t) t