Skip to content

Commit

Permalink
feat(spec): allow git@ and http urls in Plugin[1] without url=. F…
Browse files Browse the repository at this point in the history
…ixes #357
  • Loading branch information
folke committed Jan 9, 2023
1 parent d813c51 commit 4304035
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ function Spec:add(plugin, results, is_dep)
end

if not plugin.url and plugin[1] then
plugin.url = Config.options.git.url_format:format(plugin[1])
local prefix = plugin[1]:sub(1, 4)
if prefix == "http" or prefix == "git@" then
plugin.url = plugin[1]
else
plugin.url = Config.options.git.url_format:format(plugin[1])
end
end

if plugin.dir then
Expand Down
1 change: 1 addition & 0 deletions tests/core/plugin_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe("plugin spec url/name", function()
{ { dir = "~/foo" }, { name = "foo", dir = vim.fn.fnamemodify("~/foo", ":p") } },
{ { dir = "/tmp/foo" }, { dir = "/tmp/foo", name = "foo" } },
{ { "foo/bar" }, { [1] = "foo/bar", name = "bar", url = "https://github.com/foo/bar.git" } },
{ { "https://foo.bar" }, { [1] = "https://foo.bar", name = "foo.bar", url = "https://foo.bar" } },
{ { "foo/bar", name = "foobar" }, { [1] = "foo/bar", name = "foobar", url = "https://github.com/foo/bar.git" } },
{ { "foo/bar", url = "123" }, { [1] = "foo/bar", name = "123", url = "123" } },
{ { url = "https://foobar" }, { name = "foobar", url = "https://foobar" } },
Expand Down

0 comments on commit 4304035

Please sign in to comment.