diff --git a/bundle/nvim-plug/README.md b/bundle/nvim-plug/README.md index 186ad4e46..bce6893f4 100644 --- a/bundle/nvim-plug/README.md +++ b/bundle/nvim-plug/README.md @@ -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`, 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` 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 diff --git a/bundle/nvim-plug/lua/plug/config.lua b/bundle/nvim-plug/lua/plug/config.lua index 8388f3cea..2e86b71b0 100644 --- a/bundle/nvim-plug/lua/plug/config.lua +++ b/bundle/nvim-plug/lua/plug/config.lua @@ -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 diff --git a/bundle/nvim-plug/lua/plug/init.lua b/bundle/nvim-plug/lua/plug/init.lua index b191ebf1e..a60aea0a0 100644 --- a/bundle/nvim-plug/lua/plug/init.lua +++ b/bundle/nvim-plug/lua/plug/init.lua @@ -20,40 +20,44 @@ end --- @param plugins table function M.add(plugins) for _, plug in ipairs(plugins) do - loader.parser(plug) - if not plug.enabled then - goto continue - end - all_plugins[plug.name] = plug - if plug.cmds then - hooks.on_cmds(plug.cmds, plug) - end - if plug.events then - hooks.on_events(plug.events, plug) - end + if plug.depends then + M.add(plug.depends) + else + loader.parser(plug) + if not plug.enabled then + goto continue + end + all_plugins[plug.name] = plug + if plug.cmds then + hooks.on_cmds(plug.cmds, plug) + end + if plug.events then + hooks.on_events(plug.events, plug) + end - if plug.on_ft then - hooks.on_ft(plug.on_ft, plug) - end + if plug.on_ft then + hooks.on_ft(plug.on_ft, plug) + end - if plug.on_map then - hooks.on_map(plug.on_map, plug) - end + if plug.on_map then + hooks.on_map(plug.on_map, plug) + end - if plug.on_func then - hooks.on_func(plug.on_func, plug) - end + if plug.on_func then + hooks.on_func(plug.on_func, plug) + end - if - not plug.events - and not plug.cmds - and not plug.on_ft - and not plug.on_map - and not plug.on_func - then - loader.load(plug) + if + not plug.events + and not plug.cmds + and not plug.on_ft + and not plug.on_map + and not plug.on_func + then + loader.load(plug) + end + ::continue:: end - ::continue:: end end diff --git a/bundle/nvim-plug/lua/plug/installer.lua b/bundle/nvim-plug/lua/plug/installer.lua index 54ae45e22..782eda8ed 100644 --- a/bundle/nvim-plug/lua/plug/installer.lua +++ b/bundle/nvim-plug/lua/plug/installer.lua @@ -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) diff --git a/bundle/nvim-plug/test/init.lua b/bundle/nvim-plug/test/init.lua index e005bb035..2a80be376 100644 --- a/bundle/nvim-plug/test/init.lua +++ b/bundle/nvim-plug/test/init.lua @@ -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', diff --git a/bundle/nvim-plug/test/ui.lua b/bundle/nvim-plug/test/ui.lua deleted file mode 100644 index a506ada47..000000000 --- a/bundle/nvim-plug/test/ui.lua +++ /dev/null @@ -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, -})