vim.fn: throw error when trying to use API function

This commit is contained in:
smolck 2021-02-03 18:13:04 -06:00
parent 4a1a86a2be
commit e65d0e53b1

View File

@ -253,9 +253,17 @@ end
-- vim.fn.{func}(...)
vim.fn = setmetatable({}, {
__index = function(t, key)
local function _fn(...)
return vim.call(key, ...)
local _fn
if vim.api[key] ~= nil then
_fn = function(...)
error(string.format("Tried to call API function with vim.fn: use vim.api.%s() instead", key))
end
else
_fn = function(...)
return vim.call(key, ...)
end
end
t[key] = _fn
return _fn
end