aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/vim.lua
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-08-25 22:01:35 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2019-10-27 17:23:17 +0100
commit8ee7c94a92598d46b488b7fe3b1a5cff6b1bf94a (patch)
treea8f7d0b4fd659c93d2b1470e6ba6ef751eae4de9 /src/nvim/lua/vim.lua
parent19ba36d0e1bb4ef28f8aa92c7386345fbcf78cf2 (diff)
downloadrneovim-8ee7c94a92598d46b488b7fe3b1a5cff6b1bf94a.tar.gz
rneovim-8ee7c94a92598d46b488b7fe3b1a5cff6b1bf94a.tar.bz2
rneovim-8ee7c94a92598d46b488b7fe3b1a5cff6b1bf94a.zip
lua: add vim.fn.{func} for direct access to vimL function
compared to vim.api.|nvim_call_function|, this fixes some typing issues due to the indirect conversion via the API. float values are preserved as such (fixes #9389) as well as empty dicts/arrays. Ref https://github.com/norcalli/nvim.lua for the call syntax
Diffstat (limited to 'src/nvim/lua/vim.lua')
-rw-r--r--src/nvim/lua/vim.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index b67762e48e..5514819a02 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -242,6 +242,17 @@ local function __index(t, key)
end
end
+
+-- vim.fn.{func}(...)
+local function fn_index(t, key)
+ local function func(...)
+ return vim.call(key, ...)
+ end
+ t[key] = func
+ return func
+end
+local fn = setmetatable({}, {__index=fn_index})
+
local module = {
_update_package_paths = _update_package_paths,
_os_proc_children = _os_proc_children,
@@ -249,6 +260,7 @@ local module = {
_system = _system,
paste = paste,
schedule_wrap = schedule_wrap,
+ fn=fn,
}
setmetatable(module, {