also added dev.paths option

This commit is contained in:
BirdeeHub 2024-01-05 23:15:39 -08:00
commit d902783d7a
2 changed files with 23 additions and 2 deletions

View file

@ -32,6 +32,7 @@ M.defaults = {
dev = {
-- directory where you store your local plugin projects
path = "~/projects",
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

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
path = devPath
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