robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
0aa7d2f4d5
master
1#pragma once 2 3#include <lauxlib.h> 4#include <lua.h> 5#include <stdbool.h> 6 7#include "nvim/api/private/defs.h" 8#include "nvim/api/private/helpers.h" 9#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep 10#include "nvim/ex_cmds_defs.h" // IWYU pragma: keep 11#include "nvim/garray_defs.h" // IWYU pragma: keep 12#include "nvim/macros_defs.h" 13#include "nvim/types_defs.h" 14#include "nvim/usercmd.h" // IWYU pragma: keep 15 16// Generated by generators/gen_api_dispatch.lua 17void nlua_add_api_functions (lua_State * lstate )REAL_FATTR_NONNULL_ALL ; 18 19typedef struct { 20LuaRef nil_ref ; 21LuaRef empty_dict_ref ; 22int ref_count ; 23#if __has_feature (address_sanitizer ) 24PMap (int )ref_markers ; 25#endif 26}nlua_ref_state_t ; 27 28#define NLUA_EXEC_STATIC (cstr ,arg ,mode ,arena ,err ) \ 29 nlua_exec(STATIC_CSTR_AS_STRING(cstr), NULL, arg, mode, arena, err) 30 31#define NLUA_CLEAR_REF (x ) \ 32 do { \ 33/* Take the address to avoid double evaluation. #1375 */ \ 34if ((x) != LUA_NOREF) { \ 35 api_free_luaref(x); \ 36 (x) = LUA_NOREF; \ 37 } \ 38 } while (0) 39 40typedef enum { 41kRetObject ,///< any object, but doesn't preserve nested luarefs 42kRetNilBool ,///< NIL preserved as such, other values return their booleanness 43///< Should also be used when return value is ignored, as it is allocation-free 44kRetLuaref ,///< return value becomes a single Luaref, regardless of type (except NIL) 45kRetMulti ,///< like kRetObject but return multiple return values as an Array 46kRetMultiStack ,///< like kRetMulti but leave values on the lua stack 47}LuaRetMode ; 48 49/// Maximum number of errors in vim.ui_attach() and decor provider callbacks. 50enum {CB_MAX_ERROR = 3 , }; 51 52/// To use with kRetNilBool for quick truthiness check 53#define LUARET_TRUTHY (res ) ((res).type == kObjectTypeBoolean && (res).data.boolean == true) 54 55#include "lua/executor.h.generated.h" 56 57EXTERN nlua_ref_state_t * nlua_global_refs INIT (= NULL ); 58EXTERN bool nlua_disable_preload INIT (= false); 59 60/// Tracks the active Lua thread 61extern lua_State * active_lstate ; 62 63#define ENTER_LUA_ACTIVE_STATE (new_state ) \ 64 lua_State *const save_active_lstate = active_lstate; \ 65 active_lstate = (new_state); 66 67#define LEAVE_LUA_ACTIVE_STATE () \ 68 active_lstate = save_active_lstate;