mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-14 06:07:58 +08:00
fix(nvim-plug): fix clone progress
This commit is contained in:
parent
28fc69c56a
commit
2fe9e8fc11
12
bundle/nvim-plug/README.md
vendored
12
bundle/nvim-plug/README.md
vendored
@ -35,6 +35,8 @@ nvim-plug is an asynchronous Neovim plugin manager written in Lua.
|
||||
|
||||
## Usage
|
||||
|
||||
setup nvim-plug:
|
||||
|
||||
```lua
|
||||
require('plug').setup({
|
||||
bundle_dir = 'D:/bundle_dir',
|
||||
@ -43,7 +45,13 @@ require('plug').setup({
|
||||
ui = 'notify', -- default ui is `notify`, use `default` for split window UI
|
||||
http_proxy = 'http://127.0.0.1:7890', -- default is nil
|
||||
https_proxy = 'http://127.0.0.1:7890', -- default is nil
|
||||
clone_depth = 1 -- default history depth for `git clone`
|
||||
})
|
||||
```
|
||||
|
||||
add plugins:
|
||||
|
||||
```lua
|
||||
|
||||
require('plug').add({
|
||||
{
|
||||
@ -89,10 +97,12 @@ require('plug').add({
|
||||
| `build` | `string` or `table<string>`, executed by [job](https://spacevim.org/api/job/) api |
|
||||
| `enabled` | `boolean` or `function` evaluated when startup, when it is false, plugin will be skiped |
|
||||
| `frozen` | update only when specific with `PlugUpdate name` |
|
||||
| `depends` | `table<PluginSpec>` a list of plugins |
|
||||
|
||||
## Commands
|
||||
|
||||
- `:PlugInstall`: install specific plugin
|
||||
- `:PlugInstall`: install specific plugin or all plugins
|
||||
- `:PlugUpdate`: update specific plugin or all plugins
|
||||
|
||||
## Default UI
|
||||
|
||||
|
2
bundle/nvim-plug/lua/plug/config.lua
vendored
2
bundle/nvim-plug/lua/plug/config.lua
vendored
@ -11,6 +11,7 @@ M.bundle_dir = vim.fn.stdpath('data') .. '/bundle_dir'
|
||||
M.max_processes = 5
|
||||
M.base_url = 'https://github.com/'
|
||||
M.ui = 'notify'
|
||||
M.clone_depth = '1'
|
||||
function M.setup(opt)
|
||||
M.bundle_dir = opt.bundle_dir or M.bundle_dir
|
||||
M.max_processes = opt.max_processes or M.max_processes
|
||||
@ -18,6 +19,7 @@ function M.setup(opt)
|
||||
M.ui = opt.ui or M.ui
|
||||
M.http_proxy = opt.http_proxy
|
||||
M.https_proxy = opt.https_proxy
|
||||
M.clone_depth = opt.clone_depth or M.clone_depth
|
||||
end
|
||||
|
||||
return M
|
||||
|
4
bundle/nvim-plug/lua/plug/init.lua
vendored
4
bundle/nvim-plug/lua/plug/init.lua
vendored
@ -20,6 +20,9 @@ end
|
||||
--- @param plugins table<PluginSpec>
|
||||
function M.add(plugins)
|
||||
for _, plug in ipairs(plugins) do
|
||||
if plug.depends then
|
||||
M.add(plug.depends)
|
||||
else
|
||||
loader.parser(plug)
|
||||
if not plug.enabled then
|
||||
goto continue
|
||||
@ -56,6 +59,7 @@ function M.add(plugins)
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.get()
|
||||
return all_plugins
|
||||
|
32
bundle/nvim-plug/lua/plug/installer.lua
vendored
32
bundle/nvim-plug/lua/plug/installer.lua
vendored
@ -84,7 +84,11 @@ local function install_plugin(plugSpec)
|
||||
on_uidate(plugSpec.name, { command = 'clone', clone_done = true })
|
||||
return
|
||||
end
|
||||
local cmd = { 'git', 'clone', '--depth', '1', '--progress' }
|
||||
local cmd = { 'git', 'clone', '--progress' }
|
||||
if config.clone_depth ~= 0 then
|
||||
table.insert(cmd, '--depth')
|
||||
table.insert(cmd, tostring(config.clone_depth))
|
||||
end
|
||||
if plugSpec.branch then
|
||||
table.insert(cmd, '--branch')
|
||||
table.insert(cmd, plugSpec.branch)
|
||||
@ -97,17 +101,12 @@ local function install_plugin(plugSpec)
|
||||
table.insert(cmd, plugSpec.path)
|
||||
on_uidate(plugSpec.name, { command = 'clone', clone_process = '' })
|
||||
local jobid = job.start(cmd, {
|
||||
on_stdout = function(id, data)
|
||||
for _, v in ipairs(data) do
|
||||
local status = vim.fn.matchstr(v, [[\d\+%\s(\d\+/\d\+)]])
|
||||
if vim.fn.empty(status) == 1 then
|
||||
on_uidate(plugSpec.name, { clone_process = status })
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_stderr = function(id, data)
|
||||
for _, v in ipairs(data) do
|
||||
notify.notify(jobs['jobid_' .. id .. ':' .. v])
|
||||
local status = vim.fn.matchstr(v, [[\d\+%\s(\d\+/\d\+)]])
|
||||
if vim.fn.empty(status) == 0 then
|
||||
on_uidate(plugSpec.name, { clone_process = status })
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_exit = function(id, data, single)
|
||||
@ -151,17 +150,12 @@ local function update_plugin(plugSpec, force)
|
||||
local cmd = { 'git', 'pull', '--progress' }
|
||||
on_uidate(plugSpec.name, { command = 'pull', pull_process = '' })
|
||||
local jobid = job.start(cmd, {
|
||||
on_stdout = function(id, data)
|
||||
for _, v in ipairs(data) do
|
||||
local status = vim.fn.matchstr(v, [[\d\+%\s(\d\+/\d\+)]])
|
||||
if vim.fn.empty(status) == 1 then
|
||||
on_uidate(plugSpec.name, { pull_process = status })
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_stderr = function(id, data)
|
||||
for _, v in ipairs(data) do
|
||||
notify.notify(jobs['jobid_' .. id .. ':' .. v])
|
||||
local status = vim.fn.matchstr(v, [[\d\+%\s(\d\+/\d\+)]])
|
||||
if vim.fn.empty(status) == 0 then
|
||||
on_uidate(plugSpec.name, { pull_process = status })
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_exit = function(id, data, single)
|
||||
|
7
bundle/nvim-plug/test/init.lua
vendored
7
bundle/nvim-plug/test/init.lua
vendored
@ -28,7 +28,12 @@ require('plug').add({
|
||||
{
|
||||
'wsdjeg/JavaUnit.vim',
|
||||
cmds = { 'JavaUnit' },
|
||||
build = {'javac', '-encoding', 'utf8', '-d', 'bin', 'src/com/wsdjeg/util/*.java'}
|
||||
build = {'javac', '-encoding', 'utf8', '-d', 'bin', 'src/com/wsdjeg/util/*.java'},
|
||||
depends = {
|
||||
{
|
||||
'wsdjeg/syntastic'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'wsdjeg/vim-async-dict',
|
||||
|
14
bundle/nvim-plug/test/ui.lua
vendored
14
bundle/nvim-plug/test/ui.lua
vendored
@ -1,14 +0,0 @@
|
||||
local ui = require('plug.ui')
|
||||
ui.open()
|
||||
ui.on_update('test.vim', {
|
||||
clone_done = true,
|
||||
})
|
||||
ui.on_update('test2.vim', {
|
||||
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