feat: Add custom scripts and hook based setup

This commit introduces a hook system that allows the user to add custom
modules which can use these hooks to invoke function af specific NvChad
events to allow for extending og functionality
This commit is contained in:
Morten Olsen
2021-08-24 21:45:59 +02:00
committed by siduck76
parent ca1ad15ad2
commit bfc10e6034
6 changed files with 71 additions and 1 deletions

22
lua/core/custom.lua Normal file
View File

@@ -0,0 +1,22 @@
local function isModuleAvailable(name)
if package.loaded[name] then
return true
else
for _, searcher in ipairs(package.searchers or package.loaders) do
local loader = searcher(name)
if type(loader) == 'function' then
package.preload[name] = loader
return true
end
end
return false
end
end
local loadIfExists = function (module)
if isModuleAvailable(module) then
require(module)
end
end
loadIfExists('custom')