From e65d0e53b1234f9173831a8a34c4e64d5542b0cb Mon Sep 17 00:00:00 2001 From: smolck <46855713+smolck@users.noreply.github.com> Date: Wed, 3 Feb 2021 18:13:04 -0600 Subject: [PATCH] vim.fn: throw error when trying to use API function --- src/nvim/lua/vim.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index dbf4f6014c..e154404836 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -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