perf: way better compilation and caching

This commit is contained in:
Folke Lemaitre 2022-11-21 21:50:16 +01:00
parent c749404423
commit a543134b8c
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
6 changed files with 390 additions and 133 deletions

View file

@ -5,16 +5,10 @@ local M = {}
---@class LazyConfig
M.defaults = {
opt = true,
plugins = {},
plugins = "config.plugins",
plugins_local = {
path = vim.fn.expand("~/projects"),
patterns = {
"folke",
},
},
plugins_config = {
module = "plugins",
path = vim.fn.stdpath("config") .. "/lua/plugins",
patterns = {},
},
package_path = vim.fn.stdpath("data") .. "/site/pack/lazy",
}
@ -27,32 +21,11 @@ M.plugins = {}
---@type LazyConfig
M.options = {}
---@type table<string, string>
M.has_config = {}
---@param opts? LazyConfig
function M.setup(opts)
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
vim.fn.mkdir(M.options.package_path, "p")
for _, entry in ipairs(Util.scandir(M.options.plugins_config.path)) do
local name, modpath
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
if name then
M.has_config[M.options.plugins_config.module .. "." .. name] = modpath
end
end
-- vim.fn.mkdir(M.options.package_path, "p")
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",