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