From 22d8bf3861234480aa6afed90a1faaaac3d49520 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 13 Oct 2026 22:11:33 -0600 Subject: [feat] extregisters Implements "extended registers" Extended registers provide access to a separate namespace of registers backed by custom lua callback functions. A new special register ("~) is introduced, which prompts the user for the name of an extregistr to yank or paste from. This enables file-backed or cloud-synced or other arbitrary register behavior. One can now use: `"~file_extregyy` to yank into the "file_extreg" register. AI-assisted: Qwen3-Coder --- src/nvim/lua/executor.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/nvim/lua/executor.c') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index d076e53062..593cb8ebe5 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -17,6 +17,7 @@ #include "nvim/api/private/defs.h" #include "nvim/api/private/helpers.h" #include "nvim/api/ui.h" +#include "nvim/extreg.h" #include "nvim/ascii_defs.h" #include "nvim/buffer_defs.h" #include "nvim/change.h" @@ -758,6 +759,26 @@ static void nlua_common_vim_init(lua_State *lstate, bool is_thread) lua_setfield(lstate, LUA_REGISTRYINDEX, "mpack.empty_dict"); lua_setfield(lstate, -2, "_empty_dict_mt"); + // vim._extregs + lua_createtable(lstate, 0, 7); + lua_pushcfunction(lstate, &nlua_extregs_register); + lua_setfield(lstate, -2, "register"); + lua_pushcfunction(lstate, &nlua_extregs_unregister); + lua_setfield(lstate, -2, "unregister"); + lua_pushcfunction(lstate, &nlua_extregs_bind); + lua_setfield(lstate, -2, "bind"); + lua_pushcfunction(lstate, &nlua_extregs_unbind); + lua_setfield(lstate, -2, "unbind"); + lua_pushcfunction(lstate, &nlua_extregs_is_alias); + lua_setfield(lstate, -2, "is_alias"); + lua_pushcfunction(lstate, &nlua_extregs_get_provider_id); + lua_setfield(lstate, -2, "get_provider_id"); + lua_pushcfunction(lstate, &nlua_extregs_get_provider_by_id); + lua_setfield(lstate, -2, "get_provider_by_id"); + lua_pushcfunction(lstate, &nlua_extregs_get_provider); + lua_setfield(lstate, -2, "get_provider"); + lua_setfield(lstate, -2, "_extregs"); + // vim.uv if (is_thread) { luv_set_callback(lstate, nlua_luv_thread_cb_cfpcall); -- cgit