You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
my-nvim-lua/lua/core/hooks.lua

28 lines
499 B
Lua

3 years ago
local hooks, M = {}, {}
local allowed_hooks = {
["install_plugins"] = true,
["setup_mappings"] = true,
["ready"] = true,
}
M.add = function(name, fn)
if not allowed_hooks[name] then
3 years ago
print("Custom lua uses unallowed hook " .. name)
end
if not hooks[name] then
hooks[name] = {}
end
table.insert(hooks[name], fn)
end
M.run = function(name, args)
if hooks[name] then
3 years ago
for _, hook in pairs(hooks[name]) do
hook(args)
end
end
end
return M