Added performance.rtp.custom_config_dir and dev.extra_paths for nix

compatibility.
Changes to be committed:
modified:   README.md
modified:   lua/lazy/core/config.lua
modified:   lua/lazy/core/plugin.lua
This commit is contained in:
BirdeeHub 2024-01-08 23:18:23 -08:00
commit 68ef7cd3c2
3 changed files with 49 additions and 6 deletions

View file

@ -322,6 +322,8 @@ return {
dev = {
-- directory where you store your local plugin projects
path = "~/projects",
-- you may include a list of local paths to also check. e.g. { '~/projects1', '~/projects2' }
extra_paths = nil,
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"}
fallback = false, -- Fallback to git when local plugin doesn't exist
@ -424,7 +426,7 @@ return {
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
paths = {}, -- add any custom paths here that you want to includes in the rtp
paths = {}, -- add any custom paths here that you want to include in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
@ -436,6 +438,11 @@ return {
-- "tutor",
-- "zipPlugin",
},
-- custom_config_dir exists to work around circumstances
-- in which your config folder is not in the normal location,
-- and thus is unloaded when performance.rtp.reset = true
-- such as when loaded from the nix store
custom_config_dir = vim.fn.stdpath("config"),
},
},
-- lazy can generate helptags from the headings in markdown readme files,

View file

@ -32,6 +32,8 @@ M.defaults = {
dev = {
-- directory where you store your local plugin projects
path = "~/projects",
-- you may include a list of local paths to also check. e.g. { '~/projects1', '~/projects2' }
extra_paths = nil,
---@type string[] plugins that match these patterns will use your local versions instead of being fetched from GitHub
patterns = {}, -- For example {"folke"}
fallback = false, -- Fallback to git when local plugin doesn't exist
@ -134,7 +136,7 @@ M.defaults = {
rtp = {
reset = true, -- reset the runtime path to $VIMRUNTIME and your config directory
---@type string[]
paths = {}, -- add any custom paths here that you want to includes in the rtp
paths = {}, -- add any custom paths here that you want to include in the rtp
---@type string[] list any plugins you want to disable here
disabled_plugins = {
-- "gzip",
@ -146,6 +148,11 @@ M.defaults = {
-- "tutor",
-- "zipPlugin",
},
-- custom_config_dir exists to work around circumstances
-- in which your config folder is not in the normal location,
-- and thus is unloaded when performance.rtp.reset = true
-- such as when loaded from the nix store
custom_config_dir = vim.fn.stdpath("config"),
},
},
-- lazy can generate helptags from the headings in markdown readme files,
@ -212,6 +219,14 @@ function M.setup(opts)
end
table.insert(M.options.install.colorscheme, "habamax")
-- normalize path options
if type(M.options.dev.extra_paths) == "table" then
local normalized_extra_dev_paths = {}
for k, path in ipairs(M.options.dev.extra_paths) do
table.insert(normalized_extra_dev_paths, k, Util.norm(path))
end
M.options.dev.extra_paths = normalized_extra_dev_paths
end
M.options.root = Util.norm(M.options.root)
M.options.dev.path = Util.norm(M.options.dev.path)
M.options.lockfile = Util.norm(M.options.lockfile)
@ -225,14 +240,15 @@ 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"))
M.options.performance.rtp.custom_config_dir = Util.norm(M.options.performance.rtp.custom_config_dir)
if M.options.performance.rtp.reset then
vim.opt.rtp = {
vim.fn.stdpath("config"),
M.options.performance.rtp.custom_config_dir,
vim.fn.stdpath("data") .. "/site",
M.me,
vim.env.VIMRUNTIME,
vim.fn.fnamemodify(vim.v.progpath, ":p:h:h") .. "/lib/nvim",
vim.fn.stdpath("config") .. "/after",
M.options.performance.rtp.custom_config_dir .. "/after",
}
end
for _, path in ipairs(M.options.performance.rtp.paths) do

View file

@ -106,11 +106,31 @@ function Spec:add(plugin, results)
end
-- dev plugins
local devPath = nil
-- check dev.path, and if not check dev.extra_paths
-- if not found, devPath will remain nil
if plugin.dev then
if vim.fn.isdirectory(Config.options.dev.path .. "/" .. plugin.name) == 1 then
devPath = Config.options.dev.path .. "/" .. plugin.name
elseif Config.options.dev.extra_paths
and type(Config.options.dev.extra_paths) == 'table'
then
for _, path in ipairs(Config.options.dev.extra_paths) do
if vim.fn.isdirectory(path .. "/" .. plugin.name) == 1 then
devPath = path .. "/" .. plugin.name
break
end
end
end
end
-- if dev, add dev path as plugin dir, otherwise use root
if
plugin.dev
and (not Config.options.dev.fallback or vim.fn.isdirectory(Config.options.dev.path .. "/" .. plugin.name) == 1)
and (not Config.options.dev.fallback or devPath)
then
dir = Config.options.dev.path .. "/" .. plugin.name
dir = devPath
elseif plugin.dev == false then
-- explicitely select the default path
dir = Config.options.root .. "/" .. plugin.name