mirror of https://github.com/folke/lazy.nvim.git
perf: reset packpath to only include the lazy package. Improved my startup time by 2ms
This commit is contained in:
parent
5134e797f3
commit
4653119625
|
@ -10,7 +10,6 @@ M.defaults = {
|
||||||
version = nil,
|
version = nil,
|
||||||
-- version = "*", -- enable this to try installing the latest stable versions of plugins
|
-- 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.
|
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.
|
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
|
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
|
log = { "--since=1 days ago" }, -- commits from the last 3 days
|
||||||
timeout = 120, -- processes taking over 2 minutes will be killed
|
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
|
-- Any plugin spec that contains one of the patterns will use your
|
||||||
-- local repo in the projects folder instead of fetchig it from github
|
-- local repo in the projects folder instead of fetchig it from github
|
||||||
-- Mostly useful for plugin developers.
|
-- Mostly useful for plugin developers.
|
||||||
|
@ -49,6 +53,8 @@ M.defaults = {
|
||||||
M.ns = vim.api.nvim_create_namespace("lazy")
|
M.ns = vim.api.nvim_create_namespace("lazy")
|
||||||
|
|
||||||
M.paths = {
|
M.paths = {
|
||||||
|
---@type string
|
||||||
|
opt = nil,
|
||||||
---@type string
|
---@type string
|
||||||
main = nil,
|
main = nil,
|
||||||
---@type string
|
---@type string
|
||||||
|
@ -69,6 +75,11 @@ function M.setup(opts)
|
||||||
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
|
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.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.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", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
pattern = "VeryLazy",
|
pattern = "VeryLazy",
|
||||||
|
|
|
@ -147,7 +147,7 @@ end
|
||||||
function M.update_state()
|
function M.update_state()
|
||||||
---@type table<string,FileType>
|
---@type table<string,FileType>
|
||||||
local installed = {}
|
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
|
if type == "directory" or type == "link" then
|
||||||
installed[name] = type
|
installed[name] = type
|
||||||
end
|
end
|
||||||
|
@ -165,7 +165,7 @@ function M.update_state()
|
||||||
or plugin.cmd
|
or plugin.cmd
|
||||||
plugin.lazy = lazy and true or false
|
plugin.lazy = lazy and true or false
|
||||||
end
|
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_local = plugin.uri:sub(1, 4) ~= "http" and plugin.uri:sub(1, 3) ~= "git"
|
||||||
plugin._.is_symlink = installed[plugin.name] == "link"
|
plugin._.is_symlink = installed[plugin.name] == "link"
|
||||||
plugin._.installed = installed[plugin.name] ~= nil
|
plugin._.installed = installed[plugin.name] ~= nil
|
||||||
|
@ -178,7 +178,7 @@ function M.update_state()
|
||||||
for pack, dir_type in pairs(installed) do
|
for pack, dir_type in pairs(installed) do
|
||||||
table.insert(Config.to_clean, {
|
table.insert(Config.to_clean, {
|
||||||
name = pack,
|
name = pack,
|
||||||
dir = Config.options.packpath .. "/opt/" .. pack,
|
dir = Config.paths.opt .. "/" .. pack,
|
||||||
_ = {
|
_ = {
|
||||||
installed = true,
|
installed = true,
|
||||||
is_symlink = dir_type == "link",
|
is_symlink = dir_type == "link",
|
||||||
|
|
|
@ -40,8 +40,8 @@ function M.try(fn, msg)
|
||||||
end
|
end
|
||||||
if info.what == "Lua" and not info.source:find("lazy.nvim") then
|
if info.what == "Lua" and not info.source:find("lazy.nvim") then
|
||||||
local source = info.source:sub(2)
|
local source = info.source:sub(2)
|
||||||
if source:find(Config.options.packpath, 1, true) == 1 then
|
if source:find(Config.paths.opt, 1, true) == 1 then
|
||||||
source = source:sub(#Config.options.packpath + 1):gsub("^/opt/", ""):gsub("^/start/", "")
|
source = source:sub(#Config.paths.opt + 1)
|
||||||
end
|
end
|
||||||
source = vim.fn.fnamemodify(source, ":p:~:.")
|
source = vim.fn.fnamemodify(source, ":p:~:.")
|
||||||
local line = " - " .. source .. ":" .. info.currentline
|
local line = " - " .. source .. ":" .. info.currentline
|
||||||
|
|
Loading…
Reference in New Issue