feat: allow function passed to defaulttable to take an argument (#22839)

Pass the value of the key being accessed to the create function, to
allow users to dynamically generate default values.
This commit is contained in:
Gregory Anders
2023-04-01 08:02:58 -06:00
committed by GitHub
parent 6a4ebf894f
commit 643c0ed571
3 changed files with 16 additions and 5 deletions

View File

@@ -2915,6 +2915,15 @@ describe('lua stdlib', function()
return a
]])
end)
it('accepts the key name', function()
eq({ b = 'b', c = 'c' }, exec_lua [[
local a = vim.defaulttable(function(k) return k end)
local _ = a.b
local _ = a.c
return a
]])
end)
end)
it('vim.lua_omnifunc', function()