mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-13 23:27:59 +08:00
feat(nvim-plug): default ui
This commit is contained in:
parent
42cc99b36a
commit
53ccf0fdce
26
bundle/nvim-plug/README.md
vendored
26
bundle/nvim-plug/README.md
vendored
@ -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)
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
- [Intro](#intro)
|
||||
- [Features](#features)
|
||||
- [Usage](#usage)
|
||||
- [Plugin Spec](#plugin-spec)
|
||||
- [Commands](#commands)
|
||||
- [Default UI](#default-ui)
|
||||
- [Custom Plugin UI](#custom-plugin-ui)
|
||||
- [Feedback](#feedback)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## 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
|
||||
|
8
bundle/nvim-plug/lua/plug/installer.lua
vendored
8
bundle/nvim-plug/lua/plug/installer.lua
vendored
@ -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
|
||||
|
16
bundle/nvim-plug/lua/plug/ui.lua
vendored
16
bundle/nvim-plug/lua/plug/ui.lua
vendored
@ -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
|
||||
|
5
bundle/nvim-plug/test/ui.lua
vendored
5
bundle/nvim-plug/test/ui.lua
vendored
@ -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,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user