From 4304035ef4eae2d9dfac4fc082a1b391e6cd928e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Jan 2023 13:25:50 +0100 Subject: [PATCH] feat(spec): allow git@ and http urls in `Plugin[1]` without `url=`. Fixes #357 --- lua/lazy/core/plugin.lua | 7 ++++++- tests/core/plugin_spec.lua | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index d955b49..adaefae 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -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 diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua index f7d39e2..ac8b3cb 100644 --- a/tests/core/plugin_spec.lua +++ b/tests/core/plugin_spec.lua @@ -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" } },