mirror of
https://github.com/neovim/neovim.git
synced 2025-09-05 19:08:15 +00:00
perf(pack): reduce number of 'opt/' directory computations
This commit is contained in:
@@ -270,10 +270,11 @@ end
|
|||||||
--- @field info vim.pack.PlugInfo Gathered information about plugin.
|
--- @field info vim.pack.PlugInfo Gathered information about plugin.
|
||||||
|
|
||||||
--- @param spec string|vim.pack.Spec
|
--- @param spec string|vim.pack.Spec
|
||||||
|
--- @param plug_dir string?
|
||||||
--- @return vim.pack.Plug
|
--- @return vim.pack.Plug
|
||||||
local function new_plug(spec)
|
local function new_plug(spec, plug_dir)
|
||||||
local spec_resolved = normalize_spec(spec)
|
local spec_resolved = normalize_spec(spec)
|
||||||
local path = vim.fs.joinpath(get_plug_dir(), spec_resolved.name)
|
local path = vim.fs.joinpath(plug_dir or get_plug_dir(), spec_resolved.name)
|
||||||
local info = { err = '', installed = uv.fs_stat(path) ~= nil }
|
local info = { err = '', installed = uv.fs_stat(path) ~= nil }
|
||||||
return { spec = spec_resolved, path = path, info = info }
|
return { spec = spec_resolved, path = path, info = info }
|
||||||
end
|
end
|
||||||
@@ -324,6 +325,7 @@ end
|
|||||||
--- @return vim.pack.Plug[]
|
--- @return vim.pack.Plug[]
|
||||||
local function plug_list_from_names(names)
|
local function plug_list_from_names(names)
|
||||||
local all_plugins = M.get()
|
local all_plugins = M.get()
|
||||||
|
local plug_dir = get_plug_dir()
|
||||||
local plugs = {} --- @type vim.pack.Plug[]
|
local plugs = {} --- @type vim.pack.Plug[]
|
||||||
local used_names = {} --- @type table<string,boolean>
|
local used_names = {} --- @type table<string,boolean>
|
||||||
-- Preserve plugin order; might be important during checkout or event trigger
|
-- Preserve plugin order; might be important during checkout or event trigger
|
||||||
@@ -334,7 +336,7 @@ local function plug_list_from_names(names)
|
|||||||
-- TODO(echasnovski): Consider changing this if/when there is lockfile.
|
-- TODO(echasnovski): Consider changing this if/when there is lockfile.
|
||||||
--- @cast names string[]
|
--- @cast names string[]
|
||||||
if (not names and p_data.active) or vim.tbl_contains(names or {}, p_data.spec.name) then
|
if (not names and p_data.active) or vim.tbl_contains(names or {}, p_data.spec.name) then
|
||||||
plugs[#plugs + 1] = new_plug(p_data.spec)
|
plugs[#plugs + 1] = new_plug(p_data.spec, plug_dir)
|
||||||
used_names[p_data.spec.name] = true
|
used_names[p_data.spec.name] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -712,8 +714,11 @@ function M.add(specs, opts)
|
|||||||
opts = vim.tbl_extend('force', { load = vim.v.vim_did_enter == 1, confirm = true }, opts or {})
|
opts = vim.tbl_extend('force', { load = vim.v.vim_did_enter == 1, confirm = true }, opts or {})
|
||||||
vim.validate('opts', opts, 'table')
|
vim.validate('opts', opts, 'table')
|
||||||
|
|
||||||
--- @type vim.pack.Plug[]
|
local plug_dir = get_plug_dir()
|
||||||
local plugs = vim.tbl_map(new_plug, specs)
|
local plugs = {} --- @type vim.pack.Plug[]
|
||||||
|
for i = 1, #specs do
|
||||||
|
plugs[i] = new_plug(specs[i], plug_dir)
|
||||||
|
end
|
||||||
plugs = normalize_plugs(plugs)
|
plugs = normalize_plugs(plugs)
|
||||||
|
|
||||||
-- Install
|
-- Install
|
||||||
|
Reference in New Issue
Block a user