feat(util): set_upvalue
This commit is contained in:
@ -31,4 +31,20 @@ function M.get_upvalue(func, name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.set_upvalue(func, name, value)
|
||||||
|
local i = 1
|
||||||
|
while true do
|
||||||
|
local n = debug.getupvalue(func, i)
|
||||||
|
if not n then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
if n == name then
|
||||||
|
debug.setupvalue(func, i, value)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
LazyVim.error("upvalue not found: " .. name)
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
Reference in New Issue
Block a user