aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/plugin/nvim.vim1
-rw-r--r--src/nvim/lua/vim.lua9
-rw-r--r--test/functional/lua/utility_functions_spec.lua6
3 files changed, 11 insertions, 5 deletions
diff --git a/runtime/plugin/nvim.vim b/runtime/plugin/nvim.vim
deleted file mode 100644
index ffe4abc71e..0000000000
--- a/runtime/plugin/nvim.vim
+++ /dev/null
@@ -1 +0,0 @@
-lua vim.inspect = require("vim.inspect")
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index 9297af27c4..df75cc4ade 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -152,6 +152,14 @@ 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
@@ -196,6 +204,7 @@ local module = {
split = split,
gsplit = gsplit,
deepcopy = deepcopy,
+ inspect = inspect,
}
return module
diff --git a/test/functional/lua/utility_functions_spec.lua b/test/functional/lua/utility_functions_spec.lua
index 5f511f4a43..6f327ad733 100644
--- a/test/functional/lua/utility_functions_spec.lua
+++ b/test/functional/lua/utility_functions_spec.lua
@@ -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)