mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-14 05:07:59 +08:00
fix(nvim-plug): fix ui logic
This commit is contained in:
parent
90e84fefc7
commit
68b2146c17
22
bundle/nvim-plug/lua/plug/installer.lua
vendored
22
bundle/nvim-plug/lua/plug/installer.lua
vendored
@ -15,6 +15,7 @@ local config = require('plug.config')
|
||||
local on_uidate
|
||||
|
||||
--- @class PlugUiData
|
||||
--- @field command? string clone/pull/build
|
||||
--- @filed clone_process? string
|
||||
--- @filed clone_done? boolean
|
||||
--- @filed building? boolean
|
||||
@ -40,6 +41,7 @@ local function build(plugSpec)
|
||||
table.insert(building_queue, plugSpec)
|
||||
return
|
||||
end
|
||||
on_uidate(plugSpec.name, { command = 'build' })
|
||||
local jobid = job.start(plugSpec.build, {
|
||||
on_stdout = function(id, data)
|
||||
for _, v in ipairs(data) do
|
||||
@ -62,10 +64,14 @@ local function build(plugSpec)
|
||||
build(table.remove(building_queue))
|
||||
end
|
||||
end,
|
||||
cwd = plugSpec.path
|
||||
cwd = plugSpec.path,
|
||||
})
|
||||
if jobid > 0 then
|
||||
processes = processes + 1
|
||||
jobs['jobid_' .. jobid] = plugSpec.name
|
||||
else
|
||||
on_uidate(plugSpec.name, { build_done = false })
|
||||
end
|
||||
end
|
||||
|
||||
--- @param plugSpec PluginSpec
|
||||
@ -75,7 +81,7 @@ local function install_plugin(plugSpec)
|
||||
return
|
||||
elseif vim.fn.isdirectory(plugSpec.path) == 1 then
|
||||
-- if the directory exists, skip installation
|
||||
on_uidate(plugSpec.name, { clone_done = true })
|
||||
on_uidate(plugSpec.name, { command = 'clone', clone_done = true })
|
||||
return
|
||||
end
|
||||
local cmd = { 'git', 'clone', '--depth', '1', '--progress' }
|
||||
@ -89,7 +95,7 @@ local function install_plugin(plugSpec)
|
||||
|
||||
table.insert(cmd, plugSpec.url)
|
||||
table.insert(cmd, plugSpec.path)
|
||||
on_uidate(plugSpec.name, { clone_process = '' })
|
||||
on_uidate(plugSpec.name, { command = 'clone', clone_process = '' })
|
||||
local jobid = job.start(cmd, {
|
||||
on_stdout = function(id, data)
|
||||
for _, v in ipairs(data) do
|
||||
@ -134,11 +140,11 @@ local function update_plugin(plugSpec)
|
||||
return
|
||||
elseif vim.fn.isdirectory(plugSpec.path) ~= 1 then
|
||||
-- if the directory does not exist, return failed
|
||||
on_uidate(plugSpec.name, { pull_done = false })
|
||||
on_uidate(plugSpec.name, { command = 'pull', pull_done = false })
|
||||
return
|
||||
end
|
||||
local cmd = { 'git', 'pull', '--progress' }
|
||||
on_uidate(plugSpec.name, { pull_process = '' })
|
||||
on_uidate(plugSpec.name, { command = 'pull', pull_process = '' })
|
||||
local jobid = job.start(cmd, {
|
||||
on_stdout = function(id, data)
|
||||
for _, v in ipairs(data) do
|
||||
@ -160,7 +166,7 @@ local function update_plugin(plugSpec)
|
||||
build(plugSpec)
|
||||
end
|
||||
else
|
||||
on_uidate(plugSpec.name, { pull_done = false})
|
||||
on_uidate(plugSpec.name, { pull_done = false })
|
||||
end
|
||||
processes = processes - 1
|
||||
if #updating_queue > 0 then
|
||||
@ -173,8 +179,12 @@ local function update_plugin(plugSpec)
|
||||
https_proxy = config.https_proxy,
|
||||
},
|
||||
})
|
||||
if jobid > 0 then
|
||||
processes = processes + 1
|
||||
jobs['jobid_' .. jobid] = plugSpec.name
|
||||
else
|
||||
on_uidate(plugSpec.name, { pull_done = false })
|
||||
end
|
||||
end
|
||||
|
||||
M.install = function(plugSpecs)
|
||||
|
32
bundle/nvim-plug/lua/plug/ui.lua
vendored
32
bundle/nvim-plug/lua/plug/ui.lua
vendored
@ -42,28 +42,38 @@ local function build_context()
|
||||
local b = base()
|
||||
|
||||
for k, plug in pairs(plugin_status) do
|
||||
if plug.build_done then
|
||||
table.insert(b, '√ ' .. k .. ' build done')
|
||||
elseif plug.clone_done then
|
||||
table.insert(b, '√ ' .. k .. ' installed')
|
||||
elseif plug.pull_done then
|
||||
if plug.command == 'pull' then
|
||||
if plug.pull_done then
|
||||
table.insert(b, '√ ' .. k .. ' updated')
|
||||
elseif plug.clone_done == false then
|
||||
table.insert(b, '× ' .. k .. ' failed to install')
|
||||
elseif plug.pull_done == false then
|
||||
table.insert(b, '× ' .. k .. ' failed to update')
|
||||
elseif plug.build_done == false then
|
||||
table.insert(b, '× ' .. k .. ' failed to build')
|
||||
elseif plug.clone_process and plug.clone_process ~= '' then
|
||||
table.insert(b, '- ' .. k .. string.format(' cloning: %s', plug.clone_process))
|
||||
elseif plug.pull_process and plug.pull_process ~= '' then
|
||||
table.insert(b, '- ' .. k .. string.format(' updating: %s', plug.pull_process))
|
||||
else
|
||||
table.insert(b, '- ' .. k)
|
||||
end
|
||||
elseif plug.command == 'clone' then
|
||||
if plug.clone_done then
|
||||
table.insert(b, '√ ' .. k .. ' installed')
|
||||
elseif plug.clone_done == false then
|
||||
table.insert(b, '× ' .. k .. ' failed to install')
|
||||
elseif plug.clone_process and plug.clone_process ~= '' then
|
||||
table.insert(b, '- ' .. k .. string.format(' cloning: %s', plug.clone_process))
|
||||
else
|
||||
table.insert(b, '- ' .. k)
|
||||
end
|
||||
elseif plug.command == 'build' then
|
||||
if plug.build_done then
|
||||
table.insert(b, '√ ' .. k .. ' build done')
|
||||
elseif plug.build_done == false then
|
||||
table.insert(b, '× ' .. k .. ' failed to build')
|
||||
elseif plug.building == true then
|
||||
table.insert(b, '- ' .. k .. string.format(' building'))
|
||||
else
|
||||
table.insert(b, '- ' .. k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return b
|
||||
end
|
||||
|
3
bundle/nvim-plug/test/init.lua
vendored
3
bundle/nvim-plug/test/init.lua
vendored
@ -19,12 +19,15 @@ require('plug').setup({
|
||||
require('plug').add({
|
||||
{
|
||||
'wsdjeg/SourceCounter.vim',
|
||||
cmds = {'SourceCounter'}
|
||||
},
|
||||
{
|
||||
'wsdjeg/git.vim',
|
||||
cmds = {'Git'}
|
||||
},
|
||||
{
|
||||
'wsdjeg/JavaUnit.vim',
|
||||
cmds = {'JavaUnit'}
|
||||
},
|
||||
{
|
||||
'wsdjeg/vim-async-dict',
|
||||
|
Loading…
Reference in New Issue
Block a user