diff --git a/bundle/nvim-plug/README.md b/bundle/nvim-plug/README.md index aa0f17b91..5a1a93a29 100644 --- a/bundle/nvim-plug/README.md +++ b/bundle/nvim-plug/README.md @@ -7,6 +7,32 @@ **Alpha version. Any changes, including backward incompatible changes, are applied without announcements.** +![Image](https://github.com/user-attachments/assets/93b04c48-4f41-46aa-b7f7-6390ee9622c7) + + + +- [Intro](#intro) +- [Features](#features) +- [Usage](#usage) +- [Plugin Spec](#plugin-spec) +- [Commands](#commands) +- [Default UI](#default-ui) +- [Custom Plugin UI](#custom-plugin-ui) +- [Feedback](#feedback) + + + +## Intro + +nvim-plug is anasynchronous Neovim plugin manager written in Lua. + +## Features + +- **faster:** written in lua. +- **async:** downloading and building via job. +- **lazy loading:** lazy load plugin based on events, comamnd, mapping, etc.. +- **custom UI:** provide custom UI API. + ## Usage ```lua diff --git a/bundle/nvim-plug/lua/plug/installer.lua b/bundle/nvim-plug/lua/plug/installer.lua index 9aa12bc05..e0cddecca 100644 --- a/bundle/nvim-plug/lua/plug/installer.lua +++ b/bundle/nvim-plug/lua/plug/installer.lua @@ -71,7 +71,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, { downloaded = true }) + on_uidate(plugSpec.name, { clone_done = true }) return end local cmd = { 'git', 'clone', '--depth', '1', '--progress' } @@ -85,7 +85,7 @@ local function install_plugin(plugSpec) table.insert(cmd, plugSpec.url) table.insert(cmd, plugSpec.path) - on_uidate(plugSpec.name, { downloaded = false, download_process = 0 }) + on_uidate(plugSpec.name, { clone_process = 0 }) local jobid = job.start(cmd, { on_stdout = function(id, data) for _, v in ipairs(data) do @@ -102,12 +102,12 @@ local function install_plugin(plugSpec) end, on_exit = function(id, data, single) if data == 0 and single == 0 then - on_uidate(plugSpec.name, { downloaded = true, download_process = 100 }) + on_uidate(plugSpec.name, { clone_done = true, download_process = 100 }) if plugSpec.build then build(plugSpec) end else - on_uidate(plugSpec.name, { downloaded = false, download_process = 0 }) + on_uidate(plugSpec.name, { clone_done = false, download_process = 0 }) end processes = processes - 1 if #installation_queue > 0 then diff --git a/bundle/nvim-plug/lua/plug/ui.lua b/bundle/nvim-plug/lua/plug/ui.lua index c53dd4ef8..7c20cb49e 100644 --- a/bundle/nvim-plug/lua/plug/ui.lua +++ b/bundle/nvim-plug/lua/plug/ui.lua @@ -28,7 +28,7 @@ local base = function() done = count_done(plugin_status) weight = vim.api.nvim_win_get_width(winid) - 10 return { - 'plugins:(' .. done .. '/' .. total .. ')', + 'Plugins:(' .. done .. '/' .. total .. ')', '', '[' .. string.rep('=', math.floor(done / total * weight)) .. string.rep( ' ', @@ -43,9 +43,11 @@ local function build_context() for k, plug in pairs(plugin_status) do if plug.clone_done then - table.insert(b, '+ ' .. k .. ' downloaded') + table.insert(b, '√ ' .. k .. ' installed') + elseif plug.clone_done == false then + table.insert(b, '× ' .. k .. ' failed to install') else - table.insert(b, '- ' .. k .. string.format(' (%s%%)', plug.clone_process)) + table.insert(b, '- ' .. k .. string.format(' cloning: %s', plug.clone_process)) end end @@ -67,8 +69,14 @@ M.open = function() --- setup highlight vim.cmd('hi def link PlugTitle TODO') vim.cmd('hi def link PlugProcess Repeat') - vim.fn.matchadd('PlugTitle', '', 2, -1, { window = winid }) + vim.cmd('hi def link PlugDone Type') + vim.cmd('hi def link PlugFailed WarningMsg') + vim.cmd('hi def link PlugDoing Number') + vim.fn.matchadd('PlugTitle', '^Plugins.*', 2, -1, { window = winid }) vim.fn.matchadd('PlugProcess', '^\\[\\zs=*', 2, -1, { window = winid }) + vim.fn.matchadd('PlugDone', '^√.*', 2, -1, { window = winid }) + vim.fn.matchadd('PlugFailed', '^×.*', 2, -1, { window = winid }) + vim.fn.matchadd('PlugDoing', '^-.*', 2, -1, { window = winid }) end --- @class PlugUiData diff --git a/bundle/nvim-plug/test/ui.lua b/bundle/nvim-plug/test/ui.lua index 7fad243d0..a506ada47 100644 --- a/bundle/nvim-plug/test/ui.lua +++ b/bundle/nvim-plug/test/ui.lua @@ -4,8 +4,11 @@ ui.on_update('test.vim', { clone_done = true, }) ui.on_update('test2.vim', { - clone_process = '67', + clone_process = '16% (160/1000)', }) ui.on_update('test3.vim', { clone_done = true, }) +ui.on_update('test4.vim', { + clone_done = false, +})