This commit is contained in:
siduck 2022-01-07 19:58:05 +05:30
parent 799432e99e
commit 4e54ee0081
6 changed files with 26 additions and 49 deletions

View file

@ -0,0 +1,15 @@
local M = {}
local plugins = {}
M.add = function(fn)
table.insert(plugins, fn)
end
-- load custom plugins in packer startup function
M.run = function(args)
for _, hook in pairs(plugins) do
hook(args)
end
end
return M

View file

@ -1,26 +0,0 @@
local hooks, M = {}, {}
local allowed_hooks = {
["install_plugins"] = true,
["setup_mappings"] = true,
}
M.add = function(name, fn)
if not allowed_hooks[name] then
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
for _, hook in pairs(hooks[name]) do
hook(args)
end
end
end
return M

View file

@ -1,5 +1,4 @@
local utils = require "core.utils"
local hooks = require "core.hooks"
local config = utils.load_config()
local map = utils.map
@ -110,7 +109,6 @@ M.misc = function()
non_config_mappings()
optional_mappings()
required_mappings()
hooks.run("setup_mappings", map)
end
-- below are all plugin related mappings

View file

@ -223,5 +223,5 @@ return packer.startup(function()
end,
}
-- load user defined plugins
require("core.hooks").run("install_plugins", use)
require("core.customPlugins").run(use)
end)