diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 17ab65e..c992791 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -10,7 +10,6 @@ M.defaults = { version = nil, -- version = "*", -- enable this to try installing the latest stable versions of plugins }, - packpath = vim.fn.stdpath("data") .. "/site/pack/lazy", -- package path where new plugins will be installed lockfile = vim.fn.stdpath("config") .. "/lazy-lock.json", -- lockfile generated after running update. install_missing = true, -- install missing plugins on startup. This doesn't increase startup time. concurrency = nil, -- set to a number to limit the maximum amount of concurrent tasks @@ -20,6 +19,11 @@ M.defaults = { log = { "--since=1 days ago" }, -- commits from the last 3 days timeout = 120, -- processes taking over 2 minutes will be killed }, + package = { + path = vim.fn.stdpath("data") .. "/site", + name = "lazy", -- plugins will be installed under package.path/pack/{name}/opt + reset = true, -- packpath will be reset to only include lazy. This makes packadd a lot faster + }, -- Any plugin spec that contains one of the patterns will use your -- local repo in the projects folder instead of fetchig it from github -- Mostly useful for plugin developers. @@ -49,6 +53,8 @@ M.defaults = { M.ns = vim.api.nvim_create_namespace("lazy") M.paths = { + ---@type string + opt = nil, ---@type string main = nil, ---@type string @@ -69,6 +75,11 @@ function M.setup(opts) M.options = vim.tbl_deep_extend("force", M.defaults, opts or {}) M.paths.plugins = vim.fn.stdpath("config") .. "/lua/" .. M.options.plugins:gsub("%.", "/") M.paths.main = M.paths.plugins .. (vim.loop.fs_stat(M.paths.plugins .. ".lua") and ".lua" or "/init.lua") + M.paths.opt = M.options.package.path .. "/pack/" .. M.options.package.name .. "/opt" + + if M.options.package.reset then + vim.go.packpath = M.options.package.path + end vim.api.nvim_create_autocmd("User", { pattern = "VeryLazy", diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 986a28b..a6f91a5 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -147,7 +147,7 @@ end function M.update_state() ---@type table local installed = {} - Util.ls(Config.options.packpath .. "/opt", function(_, name, type) + Util.ls(Config.paths.opt, function(_, name, type) if type == "directory" or type == "link" then installed[name] = type end @@ -165,7 +165,7 @@ function M.update_state() or plugin.cmd plugin.lazy = lazy and true or false end - plugin.dir = Config.options.packpath .. "/opt/" .. plugin.name + plugin.dir = Config.paths.opt .. "/" .. plugin.name plugin._.is_local = plugin.uri:sub(1, 4) ~= "http" and plugin.uri:sub(1, 3) ~= "git" plugin._.is_symlink = installed[plugin.name] == "link" plugin._.installed = installed[plugin.name] ~= nil @@ -178,7 +178,7 @@ function M.update_state() for pack, dir_type in pairs(installed) do table.insert(Config.to_clean, { name = pack, - dir = Config.options.packpath .. "/opt/" .. pack, + dir = Config.paths.opt .. "/" .. pack, _ = { installed = true, is_symlink = dir_type == "link", diff --git a/lua/lazy/core/util.lua b/lua/lazy/core/util.lua index 8ead048..22b355d 100644 --- a/lua/lazy/core/util.lua +++ b/lua/lazy/core/util.lua @@ -40,8 +40,8 @@ function M.try(fn, msg) end if info.what == "Lua" and not info.source:find("lazy.nvim") then local source = info.source:sub(2) - if source:find(Config.options.packpath, 1, true) == 1 then - source = source:sub(#Config.options.packpath + 1):gsub("^/opt/", ""):gsub("^/start/", "") + if source:find(Config.paths.opt, 1, true) == 1 then + source = source:sub(#Config.paths.opt + 1) end source = vim.fn.fnamemodify(source, ":p:~:.") local line = " - " .. source .. ":" .. info.currentline