Lua-Client is a Neovim client and remote plugin host.
- Install this repo as a Neovim plugin using your plugin manager of choice.
- Install the lua modules: luv mpack
The development environment requires the following rocks: busted, luacheck
The script setup.sh sets up a development environment using hererocks.
See garyburd/neols.
The Nvim
type is an Nvim client.
Nvim API functions are exposed as methods on the Nvim type with the nvim_
prefix removed. Example: nvim_buf_get_var
function is exposed as
Nvim:buf_get_var(name) -> value
.
The buf, win and tabpage types are returned by several Nvim client methods.
Applications can construct values of these types using the Nvim:buf(id) -> buf
, Nvim:win(id) -> win
and Nvim:tabpage(id) -> tabpage
methods.
The buf, win and tabpage types also expose API methods with the nvim_type
prefix removed.
Example: nvim_buf_get_var
function is exposed as buf:get_var(name) -> value
.
Send RPC API request to Nvim. Normally a blocking request is sent. If the last argument is the sentinel value Nvim.notify, then an asynchronous notification is sent instead and any error returned from the method is ignored.
The following calls are identical:
nvim:request('nvim_buf_set_var', buf, 'x', 1)
nvim:buf_set_var(buf, 'x', 1) -- call method with nvim_ prefix removed
buf:set_var('x', 1) -- call method with nvim_buf_ prefix removed.
Creates a new client given a write and read uv_stream_t handles.
Creates a child process running the command cmd
and returns a client connected
to the child. Call Nvim:close()
to end the child process. Use array args
to
specify the command line arguments and table env
to specify the environment.
The args
array should typically include --embed
. If env
is not set, then
the child process environment is inherited from the current process.
Create client connected to stdin and stdout of the current process.
The client dispatches incoming requests and notifications using this table. The keys are method names and the values are the function to call.
Return a buffer given the buffer's integer id.
Return a window given the window's integer id.
Return a tabpage given the tabpage's integer id.
Send RPC API request to Nvim. Normally a blocking request is sent. If the last
argument is the sentinel value Nvim.notify
, then an asynchronous
notification is sent instead and any error returned from the method is ignored.
Nvim RPC API methods can also be called as methods on the Nvim, Buffer, Window and Tabpage types. The following calls are identical:
nvim:request('nvim_buf_set_var', buf, 'x', 1)
nvim:buf_set_var(buf, 'x', 1) -- call method with nvim_ prefix removed
buf:set_var('x', 1) -- call method with nvim_buf_ prefix removed.
Call vim function funcname
with args ...
and return the result. This method
is a helper for the following where args
is an array:
nvim:call_function(funcname, args)
Close the connection to Nvim. If the nvim process was started by new_child()
,
then the child process is closed.
This module and pmain.lua implement a Nvim plugin host. The host loads plugins from rplugin/lua/*.lua with the following globals:
- nvim - An Nvim client
- plugin - A table with functions autocmd, command and func for declaring plugin handlers.
Host is the remote plugin host.
Plugin represents an individual plugin.
Originally written by @garyburd (Gary Burd).