diff --git a/bundle/nvim-plug/lua/plug/installer.lua b/bundle/nvim-plug/lua/plug/installer.lua index 32bacc2fe..9ef4ab157 100644 --- a/bundle/nvim-plug/lua/plug/installer.lua +++ b/bundle/nvim-plug/lua/plug/installer.lua @@ -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, }) - processes = processes + 1 - jobs['jobid_' .. jobid] = plugSpec.name + 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, }, }) - processes = processes + 1 - jobs['jobid_' .. jobid] = plugSpec.name + 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) diff --git a/bundle/nvim-plug/lua/plug/ui.lua b/bundle/nvim-plug/lua/plug/ui.lua index a88f603ba..66113f022 100644 --- a/bundle/nvim-plug/lua/plug/ui.lua +++ b/bundle/nvim-plug/lua/plug/ui.lua @@ -42,26 +42,36 @@ 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 - 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)) - elseif plug.building == true then - table.insert(b, '- ' .. k .. string.format(' building')) - else - table.insert(b, '- ' .. k) + if plug.command == 'pull' then + if plug.pull_done then + table.insert(b, '√ ' .. k .. ' updated') + elseif plug.pull_done == false then + table.insert(b, '× ' .. k .. ' failed to update') + 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 diff --git a/bundle/nvim-plug/test/init.lua b/bundle/nvim-plug/test/init.lua index 6cdaa67d0..b18d5ce32 100644 --- a/bundle/nvim-plug/test/init.lua +++ b/bundle/nvim-plug/test/init.lua @@ -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',