Cleanup | Format files

* fix some lint warnings
* remove some unneeded code
This commit is contained in:
Akianonymus
2021-12-11 01:49:35 +05:30
committed by siduck
parent 773d25980c
commit 2293b16709
7 changed files with 28 additions and 40 deletions

View File

@@ -1,31 +1,23 @@
local hooks, M = {}, {}
local allowed_hooks = {
"install_plugins",
"setup_mappings",
"ready",
["install_plugins"] = true,
["setup_mappings"] = true,
["ready"] = true,
}
local function has_value(tab, val)
for _, value in ipairs(tab) do
if value == val then
return true
end
end
end
M.add = function(name, fn)
if not (has_value(allowed_hooks, name)) then
if not allowed_hooks[name] then
print("Custom lua uses unallowed hook " .. name)
end
if hooks[name] == nil then
if not hooks[name] then
hooks[name] = {}
end
table.insert(hooks[name], fn)
end
M.run = function(name, args)
if hooks[name] ~= nil then
if hooks[name] then
for _, hook in pairs(hooks[name]) do
hook(args)
end