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 uv = vim.loop
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
|
@ -2,6 +2,7 @@ local Util = require("lazy.core.util")
|
||||||
local Config = require("lazy.core.config")
|
local Config = require("lazy.core.config")
|
||||||
local Handler = require("lazy.core.handler")
|
local Handler = require("lazy.core.handler")
|
||||||
local Plugin = require("lazy.core.plugin")
|
local Plugin = require("lazy.core.plugin")
|
||||||
|
local Cache = require("lazy.core.cache")
|
||||||
|
|
||||||
---@class LazyCoreLoader
|
---@class LazyCoreLoader
|
||||||
local M = {}
|
local M = {}
|
||||||
|
@ -72,7 +73,7 @@ function M.install_missing()
|
||||||
-- remove and installed plugins from indexed, so cache will index again
|
-- remove and installed plugins from indexed, so cache will index again
|
||||||
for _, p in pairs(Config.plugins) do
|
for _, p in pairs(Config.plugins) do
|
||||||
if p._.installed then
|
if p._.installed then
|
||||||
vim.cache.reset(p.dir)
|
Cache.reset(p.dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- reload plugins
|
-- reload plugins
|
||||||
|
@ -345,7 +346,7 @@ function M.get_main(plugin)
|
||||||
local normname = Util.normname(plugin.name)
|
local normname = Util.normname(plugin.name)
|
||||||
---@type string[]
|
---@type string[]
|
||||||
local mods = {}
|
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
|
mods[#mods + 1] = modname
|
||||||
local modnorm = Util.normname(modname)
|
local modnorm = Util.normname(modname)
|
||||||
-- if we found an exact match, then use that
|
-- if we found an exact match, then use that
|
||||||
|
@ -475,7 +476,7 @@ end
|
||||||
---@param modname string
|
---@param modname string
|
||||||
function M.loader(modname)
|
function M.loader(modname)
|
||||||
local paths = Util.get_unloaded_rtp(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
|
if modpath then
|
||||||
M.auto_load(modname, modpath)
|
M.auto_load(modname, modpath)
|
||||||
local mod = package.loaded[modname]
|
local mod = package.loaded[modname]
|
||||||
|
@ -484,7 +485,7 @@ function M.loader(modname)
|
||||||
return mod
|
return mod
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return vim.cache.load(modpath, { hash = hash })
|
return Cache.load(modpath, { hash = hash })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@ function M.get_unloaded_rtp(modname)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.find_root(modname)
|
function M.find_root(modname)
|
||||||
local modpath = vim.cache.find(modname, {
|
local modpath = require("lazy.core.cache").find(modname, {
|
||||||
rtp = true,
|
rtp = true,
|
||||||
paths = M.get_unloaded_rtp(modname),
|
paths = M.get_unloaded_rtp(modname),
|
||||||
patterns = { "", ".lua" },
|
patterns = { "", ".lua" },
|
||||||
|
|
|
@ -33,11 +33,13 @@ function M.setup(spec, opts)
|
||||||
end
|
end
|
||||||
local start = vim.loop.hrtime()
|
local start = vim.loop.hrtime()
|
||||||
|
|
||||||
-- poly-fill vim.cache
|
-- disable the Neovim cache if it would ever be added
|
||||||
if not vim.cache then
|
if vim.cache and vim.cache.disable then
|
||||||
vim.cache = require("lazy.core.cache")
|
vim.cache.disable()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local Cache = require("lazy.core.cache")
|
||||||
|
|
||||||
local enable_cache = not (
|
local enable_cache = not (
|
||||||
opts
|
opts
|
||||||
and opts.performance
|
and opts.performance
|
||||||
|
@ -46,7 +48,7 @@ function M.setup(spec, opts)
|
||||||
)
|
)
|
||||||
-- load module cache before anything else
|
-- load module cache before anything else
|
||||||
if enable_cache then
|
if enable_cache then
|
||||||
vim.cache.enable()
|
Cache.enable()
|
||||||
end
|
end
|
||||||
|
|
||||||
require("lazy.stats").track("LazyStart")
|
require("lazy.stats").track("LazyStart")
|
||||||
|
@ -58,7 +60,7 @@ function M.setup(spec, opts)
|
||||||
table.insert(package.loaders, 3, Loader.loader)
|
table.insert(package.loaders, 3, Loader.loader)
|
||||||
|
|
||||||
if vim.g.profile_loaders then
|
if vim.g.profile_loaders then
|
||||||
vim.cache.profile_loaders()
|
Cache.profile_loaders()
|
||||||
end
|
end
|
||||||
|
|
||||||
Util.track({ plugin = "lazy.nvim" }) -- setup start
|
Util.track({ plugin = "lazy.nvim" }) -- setup start
|
||||||
|
|
|
@ -675,7 +675,7 @@ function M:debug()
|
||||||
end)
|
end)
|
||||||
self:nl()
|
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()
|
self:append(name, "LazyH2"):nl()
|
||||||
local props = {
|
local props = {
|
||||||
{ "total", stats.total or 0, "Number" },
|
{ "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