From 4cfe0b5315d7acac7c2adb78b671af16dc480941 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 6 Dec 2022 11:12:54 +0100 Subject: [PATCH] refactor: `Plugin.uri` => `Plugin.url` --- lua/lazy/core/plugin.lua | 16 ++++++++-------- lua/lazy/health.lua | 2 +- lua/lazy/manage/init.lua | 8 ++++---- lua/lazy/manage/task/git.lua | 2 +- lua/lazy/view/init.lua | 2 +- lua/lazy/view/render.lua | 2 +- lua/lazy/view/sections.lua | 2 +- tests/core/plugin_spec.lua | 20 ++++++++++---------- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index dc06e05..31d4a03 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -36,7 +36,7 @@ local M = {} ---@class LazyPlugin: LazyPluginHandlers,LazyPluginHooks,LazyPluginRef ---@field [1] string ---@field name string display name and name used for plugin config files ----@field uri string +---@field url string ---@field dir string ---@field enabled? boolean|(fun():boolean) ---@field lazy? boolean @@ -69,14 +69,14 @@ function Spec:add(plugin, is_dep) Util.error("Invalid plugin spec " .. vim.inspect(plugin)) end - if not plugin.uri then + if not plugin.url then local c = pkg:sub(1, 1) if c == "~" then - plugin.uri = vim.loop.os_getenv("HOME") .. pkg:sub(2) + plugin.url = vim.loop.os_getenv("HOME") .. pkg:sub(2) elseif c == "/" or pkg:sub(1, 4) == "http" or pkg:sub(1, 3) == "ssh" then - plugin.uri = pkg + plugin.url = pkg else - plugin.uri = ("https://github.com/" .. pkg .. ".git") + plugin.url = ("https://github.com/" .. pkg .. ".git") end end @@ -93,7 +93,7 @@ function Spec:add(plugin, is_dep) -- check for plugins that should be local for _, pattern in ipairs(Config.options.dev.patterns) do if plugin.dev or (plugin[1]:find(pattern, 1, true) and plugin.dev ~= false) then - plugin.uri = Config.options.dev.path .. "/" .. plugin.name + plugin.url = Config.options.dev.path .. "/" .. plugin.name break end end @@ -171,9 +171,9 @@ function M.update_state() or plugin.cmd plugin.lazy = lazy and true or false end - if plugin.uri:sub(1, 4) ~= "http" and plugin.uri:sub(1, 3) ~= "git" then + if plugin.url:sub(1, 4) ~= "http" and plugin.url:sub(1, 3) ~= "git" then plugin._.is_local = true - plugin.dir = plugin.uri + plugin.dir = plugin.url plugin._.installed = true -- user should make sure the directory exists else plugin.dir = Config.options.root .. "/" .. plugin.name diff --git a/lua/lazy/health.lua b/lua/lazy/health.lua index 612736d..d749903 100644 --- a/lua/lazy/health.lua +++ b/lua/lazy/health.lua @@ -25,7 +25,7 @@ function M.check() local valid = { 1, "name", - "uri", + "url", "enabled", "lazy", "dev", diff --git a/lua/lazy/manage/init.lua b/lua/lazy/manage/init.lua index e7e8eaa..2332d1e 100644 --- a/lua/lazy/manage/init.lua +++ b/lua/lazy/manage/init.lua @@ -62,7 +62,7 @@ function M.install(opts) "plugin.build", }, plugins = function(plugin) - return plugin.uri and not plugin._.installed + return plugin.url and not plugin._.installed end, }, opts) end @@ -81,7 +81,7 @@ function M.update(opts) { "git.log", updated = true }, }, plugins = function(plugin) - return plugin.uri and plugin._.installed + return plugin.url and plugin._.installed end, }, opts):wait(function() require("lazy.manage.lock").update() @@ -98,7 +98,7 @@ function M.check(opts) { "git.log", check = true }, }, plugins = function(plugin) - return plugin.uri and plugin._.installed + return plugin.url and plugin._.installed end, }, opts) end @@ -108,7 +108,7 @@ function M.log(opts) return M.run({ pipeline = { "git.log" }, plugins = function(plugin) - return plugin.uri and plugin._.installed + return plugin.url and plugin._.installed end, }, opts) end diff --git a/lua/lazy/manage/task/git.lua b/lua/lazy/manage/task/git.lua index d7a3992..90ba2b1 100644 --- a/lua/lazy/manage/task/git.lua +++ b/lua/lazy/manage/task/git.lua @@ -51,7 +51,7 @@ M.clone = { run = function(self) local args = { "clone", - self.plugin.uri, + self.plugin.url, "--filter=blob:none", "--recurse-submodules", "--single-branch", diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index cb0bb2b..b5db8b5 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -130,7 +130,7 @@ function M.show(mode) local function open(path) local plugin = get_plugin() if plugin then - local url = plugin.uri:gsub("%.git$", "") + local url = plugin.url:gsub("%.git$", "") if Util.file_exists(url) then url = "https://github.com/" .. plugin[1] end diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 26597ef..0f7feb5 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -363,7 +363,7 @@ end function M:details(plugin) ---@type string[][] local props = {} - table.insert(props, { "uri", (plugin.uri:gsub("%.git$", "")), "@text.reference" }) + table.insert(props, { "url", (plugin.url:gsub("%.git$", "")), "@text.reference" }) local git = Git.info(plugin.dir, true) if git then git.branch = git.branch or Git.get_branch(plugin) diff --git a/lua/lazy/view/sections.lua b/lua/lazy/view/sections.lua index 6701e90..5352c00 100644 --- a/lua/lazy/view/sections.lua +++ b/lua/lazy/view/sections.lua @@ -70,7 +70,7 @@ return { }, { filter = function(plugin) - return plugin._.installed and not plugin.uri + return plugin._.installed and not plugin.url end, title = "Clean", }, diff --git a/tests/core/plugin_spec.lua b/tests/core/plugin_spec.lua index 7562f53..be134bd 100644 --- a/tests/core/plugin_spec.lua +++ b/tests/core/plugin_spec.lua @@ -5,17 +5,17 @@ local assert = require("luassert") Config.setup() -describe("plugin spec uri/name", function() +describe("plugin spec url/name", function() local tests = { - { { "~/foo" }, { [1] = "~/foo", name = "foo", uri = vim.fn.fnamemodify("~/foo", ":p") } }, - { { "/tmp/foo" }, { [1] = "/tmp/foo", name = "foo", uri = "/tmp/foo" } }, - { { "foo/bar" }, { [1] = "foo/bar", name = "bar", uri = "https://github.com/foo/bar.git" } }, - { { "foo/bar", name = "foobar" }, { [1] = "foo/bar", name = "foobar", uri = "https://github.com/foo/bar.git" } }, - { { "foo/bar", uri = "123" }, { [1] = "foo/bar", name = "bar", uri = "123" } }, - { { "https://foobar" }, { [1] = "https://foobar", name = "foobar", uri = "https://foobar" } }, - { { "ssh://foobar" }, { [1] = "ssh://foobar", name = "foobar", uri = "ssh://foobar" } }, - { "foo/bar", { [1] = "foo/bar", name = "bar", uri = "https://github.com/foo/bar.git" } }, - { { { { "foo/bar" } } }, { [1] = "foo/bar", name = "bar", uri = "https://github.com/foo/bar.git" } }, + { { "~/foo" }, { [1] = "~/foo", name = "foo", url = vim.fn.fnamemodify("~/foo", ":p") } }, + { { "/tmp/foo" }, { [1] = "/tmp/foo", name = "foo", url = "/tmp/foo" } }, + { { "foo/bar" }, { [1] = "foo/bar", name = "bar", url = "https://github.com/foo/bar.git" } }, + { { "foo/bar", name = "foobar" }, { [1] = "foo/bar", name = "foobar", url = "https://github.com/foo/bar.git" } }, + { { "foo/bar", url = "123" }, { [1] = "foo/bar", name = "bar", url = "123" } }, + { { "https://foobar" }, { [1] = "https://foobar", name = "foobar", url = "https://foobar" } }, + { { "ssh://foobar" }, { [1] = "ssh://foobar", name = "foobar", url = "ssh://foobar" } }, + { "foo/bar", { [1] = "foo/bar", name = "bar", url = "https://github.com/foo/bar.git" } }, + { { { { "foo/bar" } } }, { [1] = "foo/bar", name = "bar", url = "https://github.com/foo/bar.git" } }, } for _, test in ipairs(tests) do