mirror of https://github.com/folke/lazy.nvim.git
feat(cache): use `vim.cache` everywhere. poly-fill when needed
This commit is contained in:
parent
4446d69c28
commit
ea1a044e3c
|
@ -183,7 +183,6 @@ function M.setup(opts)
|
|||
if type(M.options.spec) == "string" then
|
||||
M.options.spec = { import = M.options.spec }
|
||||
end
|
||||
M.options.performance.cache = require("lazy.core.cache").config
|
||||
table.insert(M.options.install.colorscheme, "habamax")
|
||||
|
||||
M.options.root = Util.norm(M.options.root)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local Util = require("lazy.core.util")
|
||||
local Config = require("lazy.core.config")
|
||||
local Handler = require("lazy.core.handler")
|
||||
local Cache = require("lazy.core.cache")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
|
||||
---@class LazyCoreLoader
|
||||
|
@ -73,7 +72,7 @@ function M.install_missing()
|
|||
-- remove and installed plugins from indexed, so cache will index again
|
||||
for _, p in pairs(Config.plugins) do
|
||||
if p._.installed then
|
||||
Cache.reset(p.dir)
|
||||
vim.cache.reset(p.dir)
|
||||
end
|
||||
end
|
||||
-- reload plugins
|
||||
|
@ -346,7 +345,7 @@ function M.get_main(plugin)
|
|||
local normname = Util.normname(plugin.name)
|
||||
---@type string[]
|
||||
local mods = {}
|
||||
for modname, _ in pairs(Cache.lsmod(plugin.dir)) do
|
||||
for modname, _ in pairs(vim.cache.lsmod(plugin.dir)) do
|
||||
mods[#mods + 1] = modname
|
||||
local modnorm = Util.normname(modname)
|
||||
-- if we found an exact match, then use that
|
||||
|
@ -476,7 +475,7 @@ end
|
|||
---@param modname string
|
||||
function M.loader(modname)
|
||||
local paths = Util.get_unloaded_rtp(modname)
|
||||
local modpath, hash = Cache.find(modname, { rtp = false, paths = paths })
|
||||
local modpath, hash = vim.cache.find(modname, { rtp = false, paths = paths })
|
||||
if modpath then
|
||||
M.auto_load(modname, modpath)
|
||||
local mod = package.loaded[modname]
|
||||
|
@ -485,7 +484,7 @@ function M.loader(modname)
|
|||
return mod
|
||||
end
|
||||
end
|
||||
return Cache.load(modpath, { hash = hash })
|
||||
return vim.cache.load(modpath, { hash = hash })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
local Config = require("lazy.core.config")
|
||||
local Util = require("lazy.core.util")
|
||||
local Handler = require("lazy.core.handler")
|
||||
local Cache = require("lazy.core.cache")
|
||||
|
||||
---@class LazyCorePlugin
|
||||
local M = {}
|
||||
|
@ -395,7 +394,6 @@ function M.load()
|
|||
Util.track("state")
|
||||
M.update_state()
|
||||
Util.track()
|
||||
require("lazy.core.cache").indexed_unloaded = false
|
||||
M.loading = false
|
||||
end
|
||||
|
||||
|
|
|
@ -241,8 +241,7 @@ function M.get_unloaded_rtp(modname)
|
|||
end
|
||||
|
||||
function M.find_root(modname)
|
||||
local Cache = require("lazy.core.cache")
|
||||
local modpath = Cache.find(modname, {
|
||||
local modpath = vim.cache.find(modname, {
|
||||
rtp = true,
|
||||
paths = M.get_unloaded_rtp(modname),
|
||||
patterns = { "", ".lua" },
|
||||
|
|
|
@ -33,15 +33,20 @@ function M.setup(spec, opts)
|
|||
end
|
||||
local start = vim.loop.hrtime()
|
||||
|
||||
-- load module cache before anything else
|
||||
-- poly-fill vim.cache
|
||||
if not vim.cache then
|
||||
vim.cache = require("lazy.core.cache")
|
||||
end
|
||||
|
||||
local enable_cache = not (
|
||||
opts
|
||||
and opts.performance
|
||||
and opts.performance.cache
|
||||
and opts.performance.cache.enabled == false
|
||||
)
|
||||
-- load module cache before anything else
|
||||
if enable_cache then
|
||||
require("lazy.core.cache").enable()
|
||||
vim.cache.enable()
|
||||
end
|
||||
|
||||
require("lazy.stats").track("LazyStart")
|
||||
|
@ -53,7 +58,7 @@ function M.setup(spec, opts)
|
|||
table.insert(package.loaders, 3, Loader.loader)
|
||||
|
||||
if vim.g.profile_loaders then
|
||||
require("lazy.core.cache").profile_loaders()
|
||||
vim.cache.profile_loaders()
|
||||
end
|
||||
|
||||
Util.track({ plugin = "lazy.nvim" }) -- setup start
|
||||
|
|
|
@ -5,7 +5,6 @@ local Handler = require("lazy.core.handler")
|
|||
local Git = require("lazy.manage.git")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
local ViewConfig = require("lazy.view.config")
|
||||
local Cache = require("lazy.core.cache")
|
||||
|
||||
local Text = require("lazy.view.text")
|
||||
|
||||
|
@ -676,7 +675,7 @@ function M:debug()
|
|||
end)
|
||||
self:nl()
|
||||
|
||||
Util.foreach(Cache.stats, function(name, stats)
|
||||
Util.foreach(vim.cache.stats, function(name, stats)
|
||||
self:append(name, "LazyH2"):nl()
|
||||
local props = {
|
||||
{ "total", stats.total or 0, "Number" },
|
||||
|
|
Loading…
Reference in New Issue