Cleanup | Format files
* fix some lint warnings * remove some unneeded code
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user