mirror of https://github.com/folke/lazy.nvim.git
refactor(cache): revert all `vim.cache` changes and disable it if it would ever exist
This commit is contained in:
parent
942c805b84
commit
21a219a825
|
@ -1,13 +1,3 @@
|
|||
---@diagnostic disable: duplicate-doc-alias
|
||||
---@diagnostic disable: duplicate-doc-field
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
|
||||
-- interop with the native Neovim cache
|
||||
if type(package.loaded["vim.cache"]) == "table" then
|
||||
return package.loaded["vim.cache"]
|
||||
end
|
||||
|
||||
-- NEOVIM
|
||||
local uv = vim.loop
|
||||
|
||||
local M = {}
|
||||
|
|
|
@ -2,6 +2,7 @@ local Util = require("lazy.core.util")
|
|||
local Config = require("lazy.core.config")
|
||||
local Handler = require("lazy.core.handler")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
local Cache = require("lazy.core.cache")
|
||||
|
||||
---@class LazyCoreLoader
|
||||
local M = {}
|
||||
|
@ -72,7 +73,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
|
||||
vim.cache.reset(p.dir)
|
||||
Cache.reset(p.dir)
|
||||
end
|
||||
end
|
||||
-- reload plugins
|
||||
|
@ -345,7 +346,7 @@ function M.get_main(plugin)
|
|||
local normname = Util.normname(plugin.name)
|
||||
---@type string[]
|
||||
local mods = {}
|
||||
for modname, _ in pairs(vim.cache.lsmod(plugin.dir)) do
|
||||
for modname, _ in pairs(Cache.lsmod(plugin.dir)) do
|
||||
mods[#mods + 1] = modname
|
||||
local modnorm = Util.normname(modname)
|
||||
-- if we found an exact match, then use that
|
||||
|
@ -475,7 +476,7 @@ end
|
|||
---@param modname string
|
||||
function M.loader(modname)
|
||||
local paths = Util.get_unloaded_rtp(modname)
|
||||
local modpath, hash = vim.cache.find(modname, { rtp = false, paths = paths })
|
||||
local modpath, hash = Cache.find(modname, { rtp = false, paths = paths })
|
||||
if modpath then
|
||||
M.auto_load(modname, modpath)
|
||||
local mod = package.loaded[modname]
|
||||
|
@ -484,7 +485,7 @@ function M.loader(modname)
|
|||
return mod
|
||||
end
|
||||
end
|
||||
return vim.cache.load(modpath, { hash = hash })
|
||||
return Cache.load(modpath, { hash = hash })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ function M.get_unloaded_rtp(modname)
|
|||
end
|
||||
|
||||
function M.find_root(modname)
|
||||
local modpath = vim.cache.find(modname, {
|
||||
local modpath = require("lazy.core.cache").find(modname, {
|
||||
rtp = true,
|
||||
paths = M.get_unloaded_rtp(modname),
|
||||
patterns = { "", ".lua" },
|
||||
|
|
|
@ -33,11 +33,13 @@ function M.setup(spec, opts)
|
|||
end
|
||||
local start = vim.loop.hrtime()
|
||||
|
||||
-- poly-fill vim.cache
|
||||
if not vim.cache then
|
||||
vim.cache = require("lazy.core.cache")
|
||||
-- disable the Neovim cache if it would ever be added
|
||||
if vim.cache and vim.cache.disable then
|
||||
vim.cache.disable()
|
||||
end
|
||||
|
||||
local Cache = require("lazy.core.cache")
|
||||
|
||||
local enable_cache = not (
|
||||
opts
|
||||
and opts.performance
|
||||
|
@ -46,7 +48,7 @@ function M.setup(spec, opts)
|
|||
)
|
||||
-- load module cache before anything else
|
||||
if enable_cache then
|
||||
vim.cache.enable()
|
||||
Cache.enable()
|
||||
end
|
||||
|
||||
require("lazy.stats").track("LazyStart")
|
||||
|
@ -58,7 +60,7 @@ function M.setup(spec, opts)
|
|||
table.insert(package.loaders, 3, Loader.loader)
|
||||
|
||||
if vim.g.profile_loaders then
|
||||
vim.cache.profile_loaders()
|
||||
Cache.profile_loaders()
|
||||
end
|
||||
|
||||
Util.track({ plugin = "lazy.nvim" }) -- setup start
|
||||
|
|
|
@ -675,7 +675,7 @@ function M:debug()
|
|||
end)
|
||||
self:nl()
|
||||
|
||||
Util.foreach(vim.cache.stats, function(name, stats)
|
||||
Util.foreach(require("lazy.core.cache").stats, function(name, stats)
|
||||
self:append(name, "LazyH2"):nl()
|
||||
local props = {
|
||||
{ "total", stats.total or 0, "Number" },
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/env bash
|
||||
cd ~/projects/neovim || exit
|
||||
sed -n '/NEOVIM/,$p' ~/projects/lazy.nvim/lua/lazy/core/cache.lua | sed '1d' | rg -v "selene" >./runtime/lua/vim/cache.lua
|
||||
stylua ./runtime/lua/vim/cache.lua
|
Loading…
Reference in New Issue