mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-07-21 12:45:13 +00:00
Merge fc85da9a7d
into 6c3bda4aca
This commit is contained in:
commit
9f647add30
2 changed files with 24 additions and 1 deletions
|
@ -315,6 +315,18 @@ function M.find_local_spec()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.find_actual_origin_spec()
|
||||||
|
local info = debug.getinfo(2, "S")
|
||||||
|
local current_file = info.source:sub(2) -- remove the leading '@'
|
||||||
|
local current_dir = vim.fn.fnamemodify(current_file, ":h")
|
||||||
|
local git_root = Util.find_git_root(current_dir)
|
||||||
|
local Git = require("lazy.manage.git")
|
||||||
|
|
||||||
|
return {
|
||||||
|
url = Git.get_origin(git_root),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
function M.load()
|
function M.load()
|
||||||
M.loading = true
|
M.loading = true
|
||||||
-- load specs
|
-- load specs
|
||||||
|
@ -326,7 +338,7 @@ function M.load()
|
||||||
vim.deepcopy(Config.options.spec),
|
vim.deepcopy(Config.options.spec),
|
||||||
}
|
}
|
||||||
specs[#specs + 1] = M.find_local_spec()
|
specs[#specs + 1] = M.find_local_spec()
|
||||||
specs[#specs + 1] = { "folke/lazy.nvim" }
|
specs[#specs + 1] = M.find_actual_origin_spec()
|
||||||
|
|
||||||
Config.spec:parse(specs)
|
Config.spec:parse(specs)
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,17 @@ function M.walk(path, fn)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param path string
|
||||||
|
function M.find_git_root(path)
|
||||||
|
local current = path
|
||||||
|
while current and current ~= "/" do
|
||||||
|
if vim.fn.isdirectory(current .. "/.git") == 1 then
|
||||||
|
return current
|
||||||
|
end
|
||||||
|
current = vim.fn.fnamemodify(current, ":h")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
---@param root string
|
---@param root string
|
||||||
---@param fn fun(modname:string, modpath:string)
|
---@param fn fun(modname:string, modpath:string)
|
||||||
---@param modname? string
|
---@param modname? string
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue