aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-14 18:08:17 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-01-14 20:12:57 +0100
commit3a84e5be8840d7fe2bf98f7f268f07489a3bb30f (patch)
treeabd088e785a89740a716494b8a30a191df384ea8 /src
parent89d7e24891c2281e301c232c4ad882b135c11bde (diff)
downloadrneovim-3a84e5be8840d7fe2bf98f7f268f07489a3bb30f.tar.gz
rneovim-3a84e5be8840d7fe2bf98f7f268f07489a3bb30f.tar.bz2
rneovim-3a84e5be8840d7fe2bf98f7f268f07489a3bb30f.zip
lua: expose full interface of vim.inspect and add test
Implement lazy loading for vim.submodule, this would be over-engineering for inspect only, but we expect to use this solution also for more and larger modules.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/lua/vim.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index df75cc4ade..b0d0bfc74b 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -152,14 +152,6 @@ local function gsplit(s, sep, plain)
end
end
-local inspect = (function()
- local f
- return function(...)
- if f == nil then f = require('vim.inspect') end
- return f(...)
- end
-end)()
-
local function split(s,sep,plain)
local t={} for c in gsplit(s, sep, plain) do table.insert(t,c) end
return t
@@ -195,6 +187,13 @@ deepcopy = function(orig)
return deepcopy_funcs[type(orig)](orig)
end
+local function __index(table, key)
+ if key == "inspect" then
+ table.inspect = require("vim.inspect")
+ return table.inspect
+ end
+end
+
local module = {
_update_package_paths = _update_package_paths,
_os_proc_children = _os_proc_children,
@@ -204,7 +203,10 @@ local module = {
split = split,
gsplit = gsplit,
deepcopy = deepcopy,
- inspect = inspect,
}
+setmetatable(module, {
+ __index = __index
+})
+
return module