diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-08-01 10:07:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 10:07:26 -0400 |
| commit | e02755cd9ff29277d14421c9df627e5dc48e4f67 (patch) | |
| tree | d3a35b8bfbf2be5accd6e572953a436a9eb8d049 /src/nvim/lua/executor.c | |
| parent | b11f1b1f76296e0296bb21a54315e2a18c8d6a6e (diff) | |
| download | rneovim-e02755cd9ff29277d14421c9df627e5dc48e4f67.tar.gz rneovim-e02755cd9ff29277d14421c9df627e5dc48e4f67.tar.bz2 rneovim-e02755cd9ff29277d14421c9df627e5dc48e4f67.zip | |
fix(options): ":set foo?" for Lua callbacks #41100
Problem:
`:set foo=<tab>` and `:set foo?` for func/expr options set to a Lua
function, always displays "v:lua".
The existing "<Lua N: file:line>" form was avoided because the ref id
N changes on every read of the same option.
Solution:
- Don't attempt to tab-complete Lua functions.
- Show "<Lua file:line>" (or "<Lua>" if source file is unknown).
Example:
:set operatorfunc?
operatorfunc=<Lua ~/.config/nvim/init.lua:42>
Diffstat (limited to 'src/nvim/lua/executor.c')
| -rw-r--r-- | src/nvim/lua/executor.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index e05da57b3c..bffa924d8f 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -2453,7 +2453,7 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview) /// String representation of a Lua function reference /// /// @return Allocated string -char *nlua_funcref_str(LuaRef ref, Arena *arena) +char *nlua_funcref_str(LuaRef ref, Arena *arena, bool show_ref) { lua_State *const lstate = global_lstate; @@ -2469,13 +2469,14 @@ char *nlua_funcref_str(LuaRef ref, Arena *arena) lua_Debug ar; if (lua_getinfo(lstate, ">S", &ar) && *ar.source == '@' && ar.linedefined >= 0) { char *src = home_replace_save(NULL, ar.source + 1); - String str = arena_printf(arena, "<Lua %d: %s:%d>", ref, src, ar.linedefined); + String str = show_ref ? arena_printf(arena, "<Lua %d: %s:%d>", ref, src, ar.linedefined) + : arena_printf(arena, "<Lua %s:%d>", src, ar.linedefined); xfree(src); return str.data; } plain: {} - return arena_printf(arena, "<Lua %d>", ref).data; + return show_ref ? arena_printf(arena, "<Lua %d>", ref).data : arena_printf(arena, "<Lua>").data; } /// Execute the vim._core.defaults module to set up default mappings and autocommands |