diff --git a/nvim/lua/psoxizsh/key/bind.lua b/nvim/lua/psoxizsh/key/bind.lua index 5c81fcd..01f63c3 100644 --- a/nvim/lua/psoxizsh/key/bind.lua +++ b/nvim/lua/psoxizsh/key/bind.lua @@ -63,6 +63,19 @@ setmetatable(Group, { return self.__children[name] end, + __newindex = function(self, name, new) + local t = type(new) == 'table' and new.__struct or nil + + if t and t == Group.__struct or t == Bind.__struct then + -- We rely on public behavior here (__call meta method) + -- should perhaps refactor the logic out of that and directly + -- call it here + self { [name] = new } + else + rawset(self, name, new) + end + end, + ---Group.__call meta method ---@param self BindGroup ---@param new table