chore: format files
This commit is contained in:
parent
317eedd9b2
commit
d810cc35a7
|
@ -4,7 +4,7 @@ local function isModuleAvailable(name)
|
||||||
else
|
else
|
||||||
for _, searcher in ipairs(package.searchers or package.loaders) do
|
for _, searcher in ipairs(package.searchers or package.loaders) do
|
||||||
local loader = searcher(name)
|
local loader = searcher(name)
|
||||||
if type(loader) == 'function' then
|
if type(loader) == "function" then
|
||||||
package.preload[name] = loader
|
package.preload[name] = loader
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -13,10 +13,10 @@ local function isModuleAvailable(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local loadIfExists = function (module)
|
local loadIfExists = function(module)
|
||||||
if isModuleAvailable(module) then
|
if isModuleAvailable(module) then
|
||||||
require(module)
|
require(module)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
loadIfExists('custom')
|
loadIfExists "custom"
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
local hooks, overrides, M = {}, {}, {};
|
local hooks, overrides, M = {}, {}, {}
|
||||||
local allowed_hooks = {
|
local allowed_hooks = {
|
||||||
"install_plugins",
|
"install_plugins",
|
||||||
"setup_mappings",
|
"setup_mappings",
|
||||||
"ready",
|
"ready",
|
||||||
}
|
}
|
||||||
|
|
||||||
local function has_value (tab, val)
|
local function has_value(tab, val)
|
||||||
for _, value in ipairs(tab) do
|
for _, value in ipairs(tab) do
|
||||||
if value == val then
|
if value == val then
|
||||||
return true
|
return true
|
||||||
|
@ -16,18 +16,18 @@ local function has_value (tab, val)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.add = function(name, fn)
|
M.add = function(name, fn)
|
||||||
if not(has_value(allowed_hooks, name)) then
|
if not (has_value(allowed_hooks, name)) then
|
||||||
error("Custom lua uses unallowed hook " .. name)
|
error("Custom lua uses unallowed hook " .. name)
|
||||||
end
|
end
|
||||||
if hooks[name] == nil then
|
if hooks[name] == nil then
|
||||||
hooks[name] = {}
|
hooks[name] = {}
|
||||||
end
|
end
|
||||||
table.insert(hooks[name], fn);
|
table.insert(hooks[name], fn)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.run = function(name, args)
|
M.run = function(name, args)
|
||||||
if hooks[name] == nil then
|
if hooks[name] == nil then
|
||||||
return;
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, hook in pairs(hooks[name]) do
|
for _, hook in pairs(hooks[name]) do
|
||||||
|
@ -36,10 +36,10 @@ M.run = function(name, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.createOverrides = function(module)
|
M.createOverrides = function(module)
|
||||||
local O = {};
|
local O = {}
|
||||||
|
|
||||||
O.get = function(name, default)
|
O.get = function(name, default)
|
||||||
local current = default;
|
local current = default
|
||||||
if overrides[module] and overrides[module][name] then
|
if overrides[module] and overrides[module][name] then
|
||||||
if type(overrides[module][name]) == "function" then
|
if type(overrides[module][name]) == "function" then
|
||||||
current = overrides[module][name]
|
current = overrides[module][name]
|
||||||
|
@ -49,21 +49,20 @@ M.createOverrides = function(module)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return current;
|
return current
|
||||||
end
|
end
|
||||||
|
|
||||||
return O;
|
return O
|
||||||
end
|
end
|
||||||
|
|
||||||
M.override = function(module, name, overwrite)
|
M.override = function(module, name, overwrite)
|
||||||
if overrides[module] == nil then
|
if overrides[module] == nil then
|
||||||
overrides[module] = {};
|
overrides[module] = {}
|
||||||
end
|
end
|
||||||
if overrides[module][name] == nil then
|
if overrides[module][name] == nil then
|
||||||
overrides[module][name] = {};
|
overrides[module][name] = {}
|
||||||
end
|
end
|
||||||
table.insert(overrides[module][name], overwrite)
|
table.insert(overrides[module][name], overwrite)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
return M;
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ local core_modules = {
|
||||||
"core.mappings",
|
"core.mappings",
|
||||||
}
|
}
|
||||||
|
|
||||||
local hooks = require('core.hooks');
|
local hooks = require "core.hooks"
|
||||||
|
|
||||||
for _, module in ipairs(core_modules) do
|
for _, module in ipairs(core_modules) do
|
||||||
local ok, err = pcall(require, module)
|
local ok, err = pcall(require, module)
|
||||||
|
@ -17,4 +17,4 @@ end
|
||||||
-- set all the non plugin mappings
|
-- set all the non plugin mappings
|
||||||
require("core.mappings").misc()
|
require("core.mappings").misc()
|
||||||
|
|
||||||
hooks.run("ready")
|
hooks.run "ready"
|
||||||
|
|
Loading…
Reference in New Issue