1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 15:19:12 +08:00

feat(plugins): implement plugins logic

This commit is contained in:
wsdjeg 2022-09-29 10:43:50 +08:00
parent 3f63663559
commit 1d43087a34

View File

@ -8,11 +8,43 @@
local M = {}
local logger = require('spacevim.logger')
function M.load()
if M.enable_plug() then
M.begin(vim.g.spacevim_plugin_bundle_dir)
M.fetch()
load_plugins()
disable_plugins(vim.g.spacevim_disabled_plugins)
M._end()
end
end
local function extend(t1, t2)
for k, v in ipairs(t2) do
t1[k] = v
end
return t1
end
local function load_plugins()
for _, layer in ipairs(require('spacevim.layer').get()) do
logger.debug('init ' .. layer .. ' layer plugins list.')
vim.g._spacevim_plugin_layer = layer
for _, plugin in ipairs(getLayerPlugins(layer)) do
if vim.fn.len(plugin) == 2 then
M.add(plugin[1], extend(plugin[2], {overwrite = 1}))
if M.tab(vim.fn.split(plugin[1], '/')[-1]) and plugin[1].loadconf then
M.defind_hooks(plugin[1], '/')
end
if M.tab(vim.fn.split(plugin[1], '/')[-1]) and plugin[1].loadconf_before then
M.loadPluginBefore(plugin[1], '/')
end
else
M.add(plugin[1], {overwrite = 1})
end
end
end
end