refactor: moved manage functionality to its own module

This commit is contained in:
Folke Lemaitre 2022-11-27 11:02:28 +01:00
parent 42c2fb42c8
commit 6dc45ada55
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
6 changed files with 22 additions and 24 deletions

View File

@ -29,7 +29,7 @@ function M.setup(opts)
for _, plugin in pairs(Config.plugins) do for _, plugin in pairs(Config.plugins) do
if not plugin.installed then if not plugin.installed then
vim.cmd("do User LazyInstallPre") vim.cmd("do User LazyInstallPre")
require("lazy.manager").install({ require("lazy.manage").install({
wait = true, wait = true,
show = Config.options.interactive, show = Config.options.interactive,
}) })

View File

@ -1,6 +1,6 @@
local Config = require("lazy.core.config") local Config = require("lazy.core.config")
local Task = require("lazy.task") local Task = require("lazy.manage.task")
local Runner = require("lazy.runner") local Runner = require("lazy.manage.runner")
local Plugin = require("lazy.core.plugin") local Plugin = require("lazy.core.plugin")
local M = {} local M = {}
@ -25,10 +25,6 @@ function M.run(operation, opts, filter)
---@type Runner ---@type Runner
local runner = Runner.new() local runner = Runner.new()
local on_done = function()
vim.cmd([[do User LazyRender]])
end
-- install missing plugins -- install missing plugins
for _, plugin in pairs(plugins) do for _, plugin in pairs(plugins) do
if filter == nil or filter(plugin) then if filter == nil or filter(plugin) then
@ -36,10 +32,6 @@ function M.run(operation, opts, filter)
end end
end end
if runner:is_empty() then
return on_done()
end
vim.cmd([[do User LazyRender]]) vim.cmd([[do User LazyRender]])
-- wait for install to finish -- wait for install to finish
@ -63,7 +55,9 @@ function M.run(operation, opts, filter)
end end
end end
-- wait for post-install to finish -- wait for post-install to finish
runner:wait(on_done) runner:wait(function()
vim.cmd([[do User LazyRender]])
end)
end) end)
if opts.wait then if opts.wait then

View File

@ -1,4 +1,4 @@
local Process = require("lazy.process") local Process = require("lazy.manage.process")
local Loader = require("lazy.core.loader") local Loader = require("lazy.core.loader")
local Util = require("lazy.util") local Util = require("lazy.util")
@ -80,8 +80,11 @@ function Task:install()
local args = { local args = {
"clone", "clone",
self.plugin.uri, self.plugin.uri,
"--depth=1", -- "--depth=1",
-- "--filter=blob:none",
"--filter=tree:0",
"--recurse-submodules", "--recurse-submodules",
"--single-branch",
"--shallow-submodules", "--shallow-submodules",
"--progress", "--progress",
} }
@ -234,6 +237,7 @@ function Task:update()
else else
local args = { local args = {
"pull", "pull",
"--tags",
"--recurse-submodules", "--recurse-submodules",
"--update-shallow", "--update-shallow",
"--progress", "--progress",

View File

@ -1,5 +1,5 @@
local View = require("lazy.view") local View = require("lazy.view")
local Manager = require("lazy.manager") local Manage = require("lazy.manage")
local Util = require("lazy.util") local Util = require("lazy.util")
local M = {} local M = {}
@ -17,31 +17,31 @@ end
M.commands = { M.commands = {
clean = function() clean = function()
Manager.clean({ clear = true, show = true }) Manage.clean({ clear = true, show = true })
end, end,
clear = function() clear = function()
Manager.clear() Manage.clear()
View.show() View.show()
end, end,
install = function() install = function()
Manager.install({ clear = true, show = true }) Manage.install({ clear = true, show = true })
end, end,
log = function() log = function()
Manager.log({ clear = true, show = true }) Manage.log({ clear = true, show = true })
end, end,
show = function() show = function()
View.show() View.show()
end, end,
docs = function() docs = function()
Manager.docs({ clear = true, show = true }) Manage.docs({ clear = true, show = true })
end, end,
sync = function() sync = function()
Manager.update({ clear = true, show = true }) Manage.update({ clear = true, show = true })
Manager.install({ show = true }) Manage.install({ show = true })
Manager.clean({ show = true }) Manage.clean({ show = true })
end, end,
update = function() update = function()
Manager.update({ clear = true, show = true }) Manage.update({ clear = true, show = true })
end, end,
} }