diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-01-09 09:02:02 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-01-13 15:07:40 +0800 |
commit | c8656e44d85502a1733df839b3cb3e8f239c5505 (patch) | |
tree | 566eaab250820ef359f8befee0b3e96374593532 /src/nvim/lua | |
parent | 70fe3ce004f1c17328257349da5528757fdcd354 (diff) | |
download | rneovim-c8656e44d85502a1733df839b3cb3e8f239c5505.tar.gz rneovim-c8656e44d85502a1733df839b3cb3e8f239c5505.tar.bz2 rneovim-c8656e44d85502a1733df839b3cb3e8f239c5505.zip |
feat(api, lua): more conversions between LuaRef and Vim Funcref
Diffstat (limited to 'src/nvim/lua')
-rw-r--r-- | src/nvim/lua/converter.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 8a702ddd60..f9a2533d4e 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -617,6 +617,13 @@ bool nlua_push_typval(lua_State *lstate, typval_T *const tv, bool special) semsg(_("E1502: Lua failed to grow stack to %i"), initial_size + 4); return false; } + if (tv->v_type == VAR_FUNC) { + ufunc_T *fp = find_func(tv->vval.v_string); + if (fp->uf_cb == nlua_CFunction_func_call) { + nlua_pushref(lstate, ((LuaCFunctionState *)fp->uf_cb_state)->lua_callable.func_ref); + return true; + } + } if (encode_vim_to_lua(lstate, tv, "nlua_push_typval argument") == FAIL) { return false; } |