lua/stdlib: Load runtime modules on-demand

Instead of eager-loading during plugin/* sourcing, define runtime
modules such as `vim.inspect` as lazy builtins. Otherwise non-builtin
Lua modules such as `vim.inspect` would not be available during startup
(init.vim, `-c`, `--cmd`, …).

ref #6580
ref #8677
This commit is contained in:
Justin M. Keyes
2019-01-14 02:05:56 +01:00
parent bb3aa824b7
commit 6c02ff4747
3 changed files with 11 additions and 5 deletions

View File

@@ -169,16 +169,14 @@ end)
describe("vim.inspect", function()
it('works', function()
command("source runtime/plugin/nvim.vim")
-- just make sure it basically works, it has its own test suite
local inspect = function(t, opts)
return meths.execute_lua('return vim.inspect(...)', { t, opts })
end
eq('2', inspect(2))
local i = inspect({ a = { b = 1 } }, { newline = '+', indent = '' })
eq('{+a = {+b = 1+}+}', i)
eq('{+a = {+b = 1+}+}',
inspect({ a = { b = 1 } }, { newline = '+', indent = '' }))
end)
end)