From 2c9473ada5b075f894d54747d2d2a2d230117d55 Mon Sep 17 00:00:00 2001 From: BirdeeHub Date: Tue, 16 Jan 2024 00:53:13 -0800 Subject: [PATCH] https://github.com/folke/lazy.nvim/pull/1157 makes dev.extra_paths unnecessary and allows for more options. Thus, this is an alternative pr to https://github.com/folke/lazy.nvim/pull/1259 that would be sufficient in conjunction with pull/1157 --- README.md | 12 ++++++++++++ lua/lazy/core/config.lua | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ebcca6a..8e606cd 100644 --- a/README.md +++ b/README.md @@ -436,6 +436,18 @@ return { -- "tutor", -- "zipPlugin", }, + -- for niche situations where you need to inject earlier in the load cycle + -- such as adding things that must be sourced before VIMRUNTIME + ---@type fun(DEFAULT: string[], ME: string, VIMRUNTIME: string, NVIM_LIB: string): string[] + override_base_rtp = function(DEFAULT, ME, VIMRUNTIME, NVIM_LIB) return DEFAULT end + -- DEFAULT = { + -- vim.fn.stdpath("config"), + -- vim.fn.stdpath("data") .. "/site", + -- ME, + -- VIMRUNTIME, + -- NVIM_LIB, + -- vim.fn.stdpath("config") .. "/after", + -- } }, }, -- lazy can generate helptags from the headings in markdown readme files, diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index 1fbf3ef..6cbba3f 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -146,6 +146,18 @@ M.defaults = { -- "tutor", -- "zipPlugin", }, + -- for niche situations where you need to inject earlier in the load cycle + -- such as adding things that must be sourced before VIMRUNTIME + ---@type fun(DEFAULT: string[], ME: string, VIMRUNTIME: string, NVIM_LIB: string): string[] + override_base_rtp = function(DEFAULT, ME, VIMRUNTIME, NVIM_LIB) return DEFAULT end + -- DEFAULT = { + -- vim.fn.stdpath("config"), + -- vim.fn.stdpath("data") .. "/site", + -- ME, + -- VIMRUNTIME, + -- NVIM_LIB, + -- vim.fn.stdpath("config") .. "/after", + -- } }, }, -- lazy can generate helptags from the headings in markdown readme files, @@ -226,14 +238,16 @@ function M.setup(opts) M.me = debug.getinfo(1, "S").source:sub(2) M.me = Util.norm(vim.fn.fnamemodify(M.me, ":p:h:h:h:h")) if M.options.performance.rtp.reset then - vim.opt.rtp = { + local NVIM_LIB = vim.fn.fnamemodify(vim.v.progpath, ":p:h:h") .. "/lib/nvim" + local base_rtp = { vim.fn.stdpath("config"), vim.fn.stdpath("data") .. "/site", M.me, vim.env.VIMRUNTIME, - vim.fn.fnamemodify(vim.v.progpath, ":p:h:h") .. "/lib/nvim", + NVIM_LIB, vim.fn.stdpath("config") .. "/after", } + vim.opt.rtp = M.options.performance.rtp.override_base_rtp(base_rtp, M.me, vim.env.VIMRUNTIME, NVIM_LIB) end for _, path in ipairs(M.options.performance.rtp.paths) do vim.opt.rtp:append(path)