mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim.fn: throw error when trying to use API function
This commit is contained in:
parent
4a1a86a2be
commit
e65d0e53b1
@ -253,9 +253,17 @@ end
|
|||||||
-- vim.fn.{func}(...)
|
-- vim.fn.{func}(...)
|
||||||
vim.fn = setmetatable({}, {
|
vim.fn = setmetatable({}, {
|
||||||
__index = function(t, key)
|
__index = function(t, key)
|
||||||
local function _fn(...)
|
local _fn
|
||||||
return vim.call(key, ...)
|
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
|
end
|
||||||
|
|
||||||
t[key] = _fn
|
t[key] = _fn
|
||||||
return _fn
|
return _fn
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user