Merge pull request #13875 from smolck/vim_fn_error_on_api

vim.fn: throw error when trying to use API function
This commit is contained in:
Björn Linse
2021-03-09 23:12:23 +01:00
committed by GitHub
2 changed files with 14 additions and 2 deletions

View File

@@ -263,8 +263,15 @@ 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