neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 5ed60804fe69e97a699ca64422f4f7f4cc20f3da
parent 2783f4cc4a410cd3b73e8cdfbdf8c859c426c6c6
Author: bfredl <bjorn.linse@gmail.com>
Date:   Wed,  9 Mar 2022 14:26:01 +0100

feat(lua): handle lazy submodules in `:lua vim.` wildmenu completion

Diffstat:
Mruntime/lua/vim/_editor.lua | 5+++++
Mtest/functional/lua/command_line_completion_spec.lua | 8++++++++
2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua @@ -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) diff --git a/test/functional/lua/command_line_completion_spec.lua b/test/functional/lua/command_line_completion_spec.lua @@ -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( {{