From 6dc45ada551f6a187473d457cb103ff7d417cc50 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 27 Nov 2022 11:02:28 +0100 Subject: [PATCH] refactor: moved manage functionality to its own module --- lua/lazy/init.lua | 2 +- lua/lazy/{manager.lua => manage/init.lua} | 16 +++++----------- lua/lazy/{ => manage}/process.lua | 0 lua/lazy/{ => manage}/runner.lua | 0 lua/lazy/{ => manage}/task.lua | 8 ++++++-- lua/lazy/view/commands.lua | 20 ++++++++++---------- 6 files changed, 22 insertions(+), 24 deletions(-) rename lua/lazy/{manager.lua => manage/init.lua} (92%) rename lua/lazy/{ => manage}/process.lua (100%) rename lua/lazy/{ => manage}/runner.lua (100%) rename lua/lazy/{ => manage}/task.lua (97%) diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua index e362191..6fbf500 100644 --- a/lua/lazy/init.lua +++ b/lua/lazy/init.lua @@ -29,7 +29,7 @@ function M.setup(opts) for _, plugin in pairs(Config.plugins) do if not plugin.installed then vim.cmd("do User LazyInstallPre") - require("lazy.manager").install({ + require("lazy.manage").install({ wait = true, show = Config.options.interactive, }) diff --git a/lua/lazy/manager.lua b/lua/lazy/manage/init.lua similarity index 92% rename from lua/lazy/manager.lua rename to lua/lazy/manage/init.lua index 1d829f7..e10693b 100644 --- a/lua/lazy/manager.lua +++ b/lua/lazy/manage/init.lua @@ -1,6 +1,6 @@ local Config = require("lazy.core.config") -local Task = require("lazy.task") -local Runner = require("lazy.runner") +local Task = require("lazy.manage.task") +local Runner = require("lazy.manage.runner") local Plugin = require("lazy.core.plugin") local M = {} @@ -25,10 +25,6 @@ function M.run(operation, opts, filter) ---@type Runner local runner = Runner.new() - local on_done = function() - vim.cmd([[do User LazyRender]]) - end - -- install missing plugins for _, plugin in pairs(plugins) do if filter == nil or filter(plugin) then @@ -36,10 +32,6 @@ function M.run(operation, opts, filter) end end - if runner:is_empty() then - return on_done() - end - vim.cmd([[do User LazyRender]]) -- wait for install to finish @@ -63,7 +55,9 @@ function M.run(operation, opts, filter) end end -- wait for post-install to finish - runner:wait(on_done) + runner:wait(function() + vim.cmd([[do User LazyRender]]) + end) end) if opts.wait then diff --git a/lua/lazy/process.lua b/lua/lazy/manage/process.lua similarity index 100% rename from lua/lazy/process.lua rename to lua/lazy/manage/process.lua diff --git a/lua/lazy/runner.lua b/lua/lazy/manage/runner.lua similarity index 100% rename from lua/lazy/runner.lua rename to lua/lazy/manage/runner.lua diff --git a/lua/lazy/task.lua b/lua/lazy/manage/task.lua similarity index 97% rename from lua/lazy/task.lua rename to lua/lazy/manage/task.lua index 3ba2296..54d26a8 100644 --- a/lua/lazy/task.lua +++ b/lua/lazy/manage/task.lua @@ -1,4 +1,4 @@ -local Process = require("lazy.process") +local Process = require("lazy.manage.process") local Loader = require("lazy.core.loader") local Util = require("lazy.util") @@ -80,8 +80,11 @@ function Task:install() local args = { "clone", self.plugin.uri, - "--depth=1", + -- "--depth=1", + -- "--filter=blob:none", + "--filter=tree:0", "--recurse-submodules", + "--single-branch", "--shallow-submodules", "--progress", } @@ -234,6 +237,7 @@ function Task:update() else local args = { "pull", + "--tags", "--recurse-submodules", "--update-shallow", "--progress", diff --git a/lua/lazy/view/commands.lua b/lua/lazy/view/commands.lua index 2d476fb..bf686d7 100644 --- a/lua/lazy/view/commands.lua +++ b/lua/lazy/view/commands.lua @@ -1,5 +1,5 @@ local View = require("lazy.view") -local Manager = require("lazy.manager") +local Manage = require("lazy.manage") local Util = require("lazy.util") local M = {} @@ -17,31 +17,31 @@ end M.commands = { clean = function() - Manager.clean({ clear = true, show = true }) + Manage.clean({ clear = true, show = true }) end, clear = function() - Manager.clear() + Manage.clear() View.show() end, install = function() - Manager.install({ clear = true, show = true }) + Manage.install({ clear = true, show = true }) end, log = function() - Manager.log({ clear = true, show = true }) + Manage.log({ clear = true, show = true }) end, show = function() View.show() end, docs = function() - Manager.docs({ clear = true, show = true }) + Manage.docs({ clear = true, show = true }) end, sync = function() - Manager.update({ clear = true, show = true }) - Manager.install({ show = true }) - Manager.clean({ show = true }) + Manage.update({ clear = true, show = true }) + Manage.install({ show = true }) + Manage.clean({ show = true }) end, update = function() - Manager.update({ clear = true, show = true }) + Manage.update({ clear = true, show = true }) end, }