mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 17:28:57 +02:00
feat(util): set_upvalue
This commit is contained in:
parent
9fe8b15928
commit
f02507b159
1 changed files with 16 additions and 0 deletions
|
@ -31,4 +31,20 @@ function M.get_upvalue(func, name)
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue