Data Structures | Macros | Functions
executor.c File Reference
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
#include "luv/luv.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/ascii.h"
#include "nvim/assert.h"
#include "nvim/buffer_defs.h"
#include "nvim/change.h"
#include "nvim/cursor.h"
#include "nvim/eval/userfunc.h"
#include "nvim/event/loop.h"
#include "nvim/event/time.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_getln.h"
#include "nvim/extmark.h"
#include "nvim/func_attr.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/lua/converter.h"
#include "nvim/lua/executor.h"
#include "nvim/lua/stdlib.h"
#include "nvim/lua/treesitter.h"
#include "nvim/macros.h"
#include "nvim/map.h"
#include "nvim/memline.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/os/os.h"
#include "nvim/screen.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/vim.h"

Data Structures

struct  LuaError


#define PUSH_ALL_TYPVALS(lstate, args, argcount, special)
#define PRINT_ERROR(msg)
#define EVALHEADER   "local _A=select(1,...) return ("
#define CALLHEADER   "return "
#define CALLSUFFIX   "(...)"
#define DOSTART   "return function(line, linenr) "
#define DOEND   " end"


void nlua_init (void)
void nlua_free_all_mem (void)
int nlua_in_fast_event (lua_State *lstate)
int nlua_call (lua_State *lstate)
LuaRef nlua_ref (lua_State *lstate, int index)
 add the value to the registry More...
void nlua_unref (lua_State *lstate, LuaRef ref)
 remove the value from the registry More...
void api_free_luaref (LuaRef ref)
void nlua_pushref (lua_State *lstate, LuaRef ref)
 push a value referenced in the registry More...
LuaRef api_new_luaref (LuaRef original_ref)
void nlua_typval_eval (const String str, typval_T *const arg, typval_T *const ret_tv) FUNC_ATTR_NONNULL_ALL
void nlua_typval_call (const char *str, size_t len, typval_T *const args, int argcount, typval_T *ret_tv) FUNC_ATTR_NONNULL_ALL
int nlua_source_using_linegetter (LineGetter fgetline, void *cookie, char *name)
int typval_exec_lua_callable (lua_State *lstate, LuaCallable lua_cb, int argcount, typval_T *argvars, typval_T *rettv)
Object nlua_exec (const String str, const Array args, Error *err)
Object nlua_call_ref (LuaRef ref, const char *name, Array args, bool retval, Error *err)
bool nlua_is_deferred_safe (void)
void ex_lua (exarg_T *const eap) FUNC_ATTR_NONNULL_ALL
void ex_luado (exarg_T *const eap) FUNC_ATTR_NONNULL_ALL
void ex_luafile (exarg_T *const eap) FUNC_ATTR_NONNULL_ALL
bool nlua_exec_file (const char *path) FUNC_ATTR_NONNULL_ALL
int tslua_get_language_version (lua_State *L)
int nlua_expand_pat (expand_T *xp, char_u *pat, int *num_results, char_u ***results)
int nlua_CFunction_func_call (int argcount, typval_T *argvars, typval_T *rettv, void *state)
void nlua_CFunction_func_free (void *state)
bool nlua_is_table_from_lua (typval_T *const arg)
char_unlua_register_table_as_callable (typval_T *const arg)
void nlua_execute_on_key (int c)

Macro Definition Documentation


#define CALLHEADER   "return "


#define CALLSUFFIX   "(...)"


#define DOEND   " end"


#define DOSTART   "return function(line, linenr) "


#define EVALHEADER   "local _A=select(1,...) return ("


#define PRINT_ERROR (   msg)
do { \
errmsg = msg; \
errmsg_len = sizeof(msg) - 1; \
goto nlua_print_error; \
} while (0)


#define PUSH_ALL_TYPVALS (   lstate,
for (int i = 0; i < argcount; i++) { \
if (args[i].v_type == VAR_UNKNOWN) { \
lua_pushnil(lstate); \
} else { \
nlua_push_typval(lstate, &args[i], special); \
} \

Function Documentation

◆ api_free_luaref()

void api_free_luaref ( LuaRef  ref)

◆ api_new_luaref()

LuaRef api_new_luaref ( LuaRef  original_ref)

Gets a new reference to an object stored at original_ref

NOTE: It does not copy the value, it creates a new ref to the lua object. Leaves the stack unchanged.

◆ ex_lua()

void ex_lua ( exarg_T *const  eap)

Run lua string

Used for :lua.

eapVimL command being run.

◆ ex_luado()

void ex_luado ( exarg_T *const  eap)

Run lua string for each line in range

Used for :luado.

eapVimL command being run.

◆ ex_luafile()

void ex_luafile ( exarg_T *const  eap)

Run lua file

Used for :luafile.

eapVimL command being run.

◆ nlua_call()

int nlua_call ( lua_State *  lstate)

◆ nlua_call_ref()

Object nlua_call_ref ( LuaRef  ref,
const char *  name,
Array  args,
bool  retval,
Error err 

call a LuaRef as a function (or table with __call metamethod)

refthe reference to call (not consumed)
nameif non-NULL, sent to callback as first arg if NULL, only args are used
retvalif true, convert return value to Object if false, discard return value
errError details, if any (if NULL, errors are echoed)
Return value of function, if retval was set. Otherwise NIL.

◆ nlua_CFunction_func_call()

int nlua_CFunction_func_call ( int  argcount,
typval_T argvars,
typval_T rettv,
void state 

◆ nlua_CFunction_func_free()

void nlua_CFunction_func_free ( void state)

◆ nlua_exec()

Object nlua_exec ( const String  str,
const Array  args,
Error err 

Execute Lua string

Used for nvim_exec_lua() and internally to execute a lua string.

[in]strString to execute.
[in]argsarray of ... args
[out]errLocation where error will be saved.
Return value of the execution.

◆ nlua_exec_file()

bool nlua_exec_file ( const char *  path)

execute lua code from a file.

pathpath of the file
true if everything ok, false if there was an error (echoed)

◆ nlua_execute_on_key()

void nlua_execute_on_key ( int  c)

◆ nlua_expand_pat()

int nlua_expand_pat ( expand_T xp,
char_u pat,
int *  num_results,
char_u ***  results 

◆ nlua_free_all_mem()

void nlua_free_all_mem ( void  )

◆ nlua_in_fast_event()

int nlua_in_fast_event ( lua_State *  lstate)

◆ nlua_init()

void nlua_init ( void  )

Initialize global lua interpreter

Crashes Nvim if initialization fails.

◆ nlua_is_deferred_safe()

bool nlua_is_deferred_safe ( void  )

check if the current execution context is safe for calling deferred API methods. Luv callbacks are unsafe as they are called inside the uv loop.

◆ nlua_is_table_from_lua()

bool nlua_is_table_from_lua ( typval_T *const  arg)

◆ nlua_pushref()

void nlua_pushref ( lua_State *  lstate,
LuaRef  ref 

push a value referenced in the registry

◆ nlua_ref()

LuaRef nlua_ref ( lua_State *  lstate,
int  index 

add the value to the registry

◆ nlua_register_table_as_callable()

char_u* nlua_register_table_as_callable ( typval_T *const  arg)

◆ nlua_source_using_linegetter()

int nlua_source_using_linegetter ( LineGetter  fgetline,
void cookie,
char *  name 

◆ nlua_typval_call()

void nlua_typval_call ( const char *  str,
size_t  len,
typval_T *const  args,
int  argcount,
typval_T ret_tv 

◆ nlua_typval_eval()

void nlua_typval_eval ( const String  str,
typval_T *const  arg,
typval_T *const  ret_tv 

Evaluate lua string

Used for luaeval().

[in]strString to execute.
[in]argSecond argument to luaeval().
[out]ret_tvLocation where result will be saved.
Result of the execution.

◆ nlua_unref()

void nlua_unref ( lua_State *  lstate,
LuaRef  ref 

remove the value from the registry

◆ tslua_get_language_version()

int tslua_get_language_version ( lua_State *  L)

◆ typval_exec_lua_callable()

int typval_exec_lua_callable ( lua_State *  lstate,
LuaCallable  lua_cb,
int  argcount,
typval_T argvars,
typval_T rettv 

Call a LuaCallable given some typvals

Used to call any lua callable passed from Lua into VimL

[in]lstateLua State
[in]lua_cbLua Callable
[in]argcountCount of typval arguments
[in]argvarsTypval Arguments
[out]rettvThe return value from the called function.
static void int i
Definition: edit.c:2997
Unknown (unspecified) value.
Definition: typval.h:116
err msg
Definition: helpers.c:1039
void argv[0] v_type
Definition: typval.c:1273
va_list args
Definition: log.c:149