2022-11-20 21:33:47 +00:00
|
|
|
local Util = require("lazy.util")
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
---@class LazyConfig
|
|
|
|
M.defaults = {
|
2022-11-20 21:34:55 +00:00
|
|
|
opt = true,
|
|
|
|
plugins = {},
|
|
|
|
plugins_local = {
|
|
|
|
path = vim.fn.expand("~/projects"),
|
|
|
|
patterns = {
|
|
|
|
"folke",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins_config = {
|
|
|
|
module = "plugins",
|
|
|
|
path = vim.fn.stdpath("config") .. "/lua/plugins",
|
|
|
|
},
|
|
|
|
package_path = vim.fn.stdpath("data") .. "/site/pack/lazy",
|
2022-11-20 21:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
M.ns = vim.api.nvim_create_namespace("lazy")
|
|
|
|
|
|
|
|
---@type table<string, LazyPlugin>
|
|
|
|
M.plugins = {}
|
|
|
|
|
|
|
|
---@type LazyConfig
|
|
|
|
M.options = {}
|
|
|
|
|
|
|
|
---@type table<string, string>
|
|
|
|
M.has_config = {}
|
|
|
|
|
|
|
|
---@param opts? LazyConfig
|
|
|
|
function M.setup(opts)
|
2022-11-20 21:34:55 +00:00
|
|
|
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
vim.fn.mkdir(M.options.package_path, "p")
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
for _, entry in ipairs(Util.scandir(M.options.plugins_config.path)) do
|
|
|
|
local name, modpath
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
if entry.type == "file" then
|
|
|
|
modpath = entry.path
|
|
|
|
name = entry.name:match("(.*)%.lua")
|
|
|
|
elseif entry.type == "directory" then
|
|
|
|
modpath = M.options.plugins_config.path .. "/" .. entry.name .. "/init.lua"
|
|
|
|
if vim.loop.fs_stat(modpath) then
|
|
|
|
name = entry.name
|
|
|
|
end
|
|
|
|
end
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
if name then
|
|
|
|
M.has_config[M.options.plugins_config.module .. "." .. name] = modpath
|
|
|
|
end
|
|
|
|
end
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
vim.api.nvim_create_autocmd("User", {
|
|
|
|
pattern = "VeryLazy",
|
|
|
|
once = true,
|
|
|
|
callback = function()
|
|
|
|
-- require("lazy.view").setup()
|
|
|
|
end,
|
|
|
|
})
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
Util.very_lazy()
|
2022-11-20 21:33:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|