Merge pull request #17660 from bfredl/luacomplete

feat(lua): handle lazy submodules in `:lua vim.` wildmenu completion
This commit is contained in:
bfredl 2022-03-10 15:46:18 +01:00 committed by GitHub
commit 6170574d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -519,6 +519,8 @@ function vim._expand_pat(pat, env)
local mt = getmetatable(final_env)
if mt and type(mt.__index) == "table" then
field = rawget(mt.__index, key)
elseif final_env == vim and vim._submodules[key] then
field = vim[key]
end
end
final_env = field
@ -545,6 +547,9 @@ function vim._expand_pat(pat, env)
if mt and type(mt.__index) == "table" then
insert_keys(mt.__index)
end
if final_env == vim then
insert_keys(vim._submodules)
end
table.sort(keys)

View File

@ -106,6 +106,14 @@ describe('nlua_expand_pat', function()
)
end)
it('should work with lazy submodules of "vim" global', function()
eq({{ 'inspect' }, 4 },
get_completions('vim.inspec'))
eq({{ 'set' }, 11 },
get_completions('vim.keymap.se'))
end)
it('should be able to interpolate globals', function()
eq(
{{