mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user