mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-28 11:24:14 +00:00
Added 2 options for nix compatibility
Fully backwards compatible with minimal runtime impact dev.extra_paths and performance.rtp.override_base_rtp
This commit is contained in:
parent
96584866b9
commit
5f41e57c5e
4 changed files with 70 additions and 6 deletions
16
README.md
16
README.md
|
@ -322,6 +322,8 @@ return {
|
|||
dev = {
|
||||
-- directory where you store your local plugin projects
|
||||
path = "~/projects",
|
||||
---@type string[] | nil you may include a list of local paths to also check
|
||||
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 append to the rtp
|
||||
---@type string[] list any plugins you want to disable here
|
||||
disabled_plugins = {
|
||||
-- "gzip",
|
||||
|
@ -436,6 +438,18 @@ return {
|
|||
-- "tutor",
|
||||
-- "zipPlugin",
|
||||
},
|
||||
-- for niche situations where lazy breaks oddly built configurations
|
||||
-- such as those that can be produced via nix.
|
||||
---@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,
|
||||
|
|
|
@ -32,6 +32,8 @@ M.defaults = {
|
|||
dev = {
|
||||
-- directory where you store your local plugin projects
|
||||
path = "~/projects",
|
||||
---@type string[] | nil you may include a list of local paths to also check
|
||||
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 append to the rtp
|
||||
---@type string[] list any plugins you want to disable here
|
||||
disabled_plugins = {
|
||||
-- "gzip",
|
||||
|
@ -146,6 +148,18 @@ M.defaults = {
|
|||
-- "tutor",
|
||||
-- "zipPlugin",
|
||||
},
|
||||
-- for niche situations where lazy breaks oddly built configurations
|
||||
-- such as those that can be produced via nix.
|
||||
---@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,
|
||||
|
@ -212,6 +226,7 @@ function M.setup(opts)
|
|||
end
|
||||
table.insert(M.options.install.colorscheme, "habamax")
|
||||
|
||||
M.options.dev.extra_paths = Util.norm_list(M.options.dev.extra_paths)
|
||||
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)
|
||||
|
@ -226,14 +241,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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -64,6 +64,19 @@ function M.norm(path)
|
|||
return path:sub(-1) == "/" and path:sub(1, -2) or path
|
||||
end
|
||||
|
||||
---@return table | nil
|
||||
function M.norm_list(list)
|
||||
if M.is_list(list) then
|
||||
local normalized_paths = {}
|
||||
for k, path in ipairs(list) do
|
||||
table.insert(normalized_paths, k, M.norm(path))
|
||||
end
|
||||
return normalized_paths
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
---@param opts? {level?: number}
|
||||
function M.pretty_trace(opts)
|
||||
opts = opts or {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue