From 3df8d9b8c56a7f0af0f7590b11831bd96ead92f1 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Wed, 3 Aug 2022 14:41:17 +0200 Subject: feat(lua): print source locations of lua callbacks (#19597) Co-authored-by: ii14 --- src/nvim/lua/executor.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 17157ccdc2..197a209e97 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -2076,3 +2076,34 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview) return retv; } + +/// String representation of a Lua function reference +/// +/// @return Allocated string +char *nlua_funcref_str(LuaRef ref) +{ + lua_State *const lstate = global_lstate; + StringBuilder str = KV_INITIAL_VALUE; + kv_resize(str, 16); + + if (!lua_checkstack(lstate, 1)) { + goto plain; + } + nlua_pushref(lstate, ref); + if (!lua_isfunction(lstate, -1)) { + lua_pop(lstate, 1); + goto plain; + } + + lua_Debug ar; + if (lua_getinfo(lstate, ">S", &ar) && *ar.source == '@' && ar.linedefined >= 0) { + char *src = home_replace_save(NULL, ar.source + 1); + kv_printf(str, "", ref, src, ar.linedefined); + xfree(src); + return str.items; + } + +plain: + kv_printf(str, "", ref); + return str.items; +} -- cgit From ad7064bd83aef7caadb51c988c0dcb9054624fcf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 6 Aug 2022 17:14:37 +0800 Subject: vim-patch:8.1.1210: support for user commands is spread out (#19653) Problem: Support for user commands is spread out. No good reason to make user commands optional. Solution: Move user command support to usercmd.c. Always enable the user_commands feature. https://github.com/vim/vim/commit/ac9fb18020d7e8bf16d02d45fbb02cf47328aaf7 --- src/nvim/lua/executor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 197a209e97..661dbfc4c2 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -21,7 +21,6 @@ #include "nvim/event/loop.h" #include "nvim/event/time.h" #include "nvim/ex_cmds2.h" -#include "nvim/ex_docmd.h" #include "nvim/ex_getln.h" #include "nvim/extmark.h" #include "nvim/func_attr.h" @@ -40,6 +39,7 @@ #include "nvim/profile.h" #include "nvim/screen.h" #include "nvim/undo.h" +#include "nvim/usercmd.h" #include "nvim/version.h" #include "nvim/vim.h" #include "nvim/window.h" -- cgit