neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 92e7d5eaf2a9f0950c2c5023f536d4500342f461
parent d73cfefed5e45fec91a422cd87054611ff711b30
Author: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
Date:   Fri, 22 Aug 2025 12:53:13 +0300

perf(pack): reduce number of 'opt/' directory computations

Diffstat:
Mruntime/lua/vim/pack.lua | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua @@ -270,10 +270,11 @@ end --- @field info vim.pack.PlugInfo Gathered information about plugin. --- @param spec string|vim.pack.Spec +--- @param plug_dir string? --- @return vim.pack.Plug -local function new_plug(spec) +local function new_plug(spec, plug_dir) 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 } return { spec = spec_resolved, path = path, info = info } end @@ -324,6 +325,7 @@ end --- @return vim.pack.Plug[] local function plug_list_from_names(names) local all_plugins = M.get() + local plug_dir = get_plug_dir() local plugs = {} --- @type vim.pack.Plug[] local used_names = {} --- @type table<string,boolean> -- 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. --- @cast names string[] 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 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 {}) vim.validate('opts', opts, 'table') - --- @type vim.pack.Plug[] - local plugs = vim.tbl_map(new_plug, specs) + local plug_dir = get_plug_dir() + local plugs = {} --- @type vim.pack.Plug[] + for i = 1, #specs do + plugs[i] = new_plug(specs[i], plug_dir) + end plugs = normalize_plugs(plugs) -- Install