diff --git a/bundle/nvim-plug/README.md b/bundle/nvim-plug/README.md index a1dbe55bd..e752aba13 100644 --- a/bundle/nvim-plug/README.md +++ b/bundle/nvim-plug/README.md @@ -88,6 +88,7 @@ require('plug').add({ | `type` | `string`, plugin type including `color`, `plugin` | | `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` | ## Commands diff --git a/bundle/nvim-plug/lua/plug/installer.lua b/bundle/nvim-plug/lua/plug/installer.lua index 9ef4ab157..e9f01d35f 100644 --- a/bundle/nvim-plug/lua/plug/installer.lua +++ b/bundle/nvim-plug/lua/plug/installer.lua @@ -134,14 +134,17 @@ local function install_plugin(plugSpec) end --- @param plugSpec PluginSpec -local function update_plugin(plugSpec) +local function update_plugin(plugSpec, force) if processes >= config.max_processes then - table.insert(updating_queue, plugSpec) + table.insert(updating_queue, {plugSpec, force}) return elseif vim.fn.isdirectory(plugSpec.path) ~= 1 then -- if the directory does not exist, return failed on_uidate(plugSpec.name, { command = 'pull', pull_done = false }) return + elseif plugSpec.frozen and not force then + on_uidate(plugSpec.name, { command = 'pull', pull_done = true }) + return end local cmd = { 'git', 'pull', '--progress' } on_uidate(plugSpec.name, { command = 'pull', pull_process = '' }) @@ -170,7 +173,7 @@ local function update_plugin(plugSpec) end processes = processes - 1 if #updating_queue > 0 then - update_plugin(table.remove(updating_queue, 1)) + update_plugin(unpack(table.remove(updating_queue, 1))) end end, cwd = plugSpec.path, @@ -193,9 +196,9 @@ M.install = function(plugSpecs) end end -M.update = function(plugSpecs) +M.update = function(plugSpecs, force) for _, v in ipairs(plugSpecs) do - update_plugin(v) + update_plugin(v, force) end end diff --git a/bundle/nvim-plug/lua/plug/loader.lua b/bundle/nvim-plug/lua/plug/loader.lua index 5c9a3f613..730a54efd 100644 --- a/bundle/nvim-plug/lua/plug/loader.lua +++ b/bundle/nvim-plug/lua/plug/loader.lua @@ -22,6 +22,7 @@ local config = require('plug.config') --- @field build string|table --- @field is_local boolean true for local plugin --- @field when boolean|string|function +--- @field frozen boolean local function is_local_plugin(plugSpec) if plugSpec.is_local or vim.fn.isdirectory(plugSpec[1]) == 1 then diff --git a/bundle/nvim-plug/plugin/plug.lua b/bundle/nvim-plug/plugin/plug.lua index 693a336bb..240c7ea5f 100644 --- a/bundle/nvim-plug/plugin/plug.lua +++ b/bundle/nvim-plug/plugin/plug.lua @@ -44,7 +44,7 @@ vim.api.nvim_create_user_command('PlugUpdate', function(opt) for _, v in pairs(all_plugins) do table.insert(plugs, v) end - require('plug.installer').update(plugs) + require('plug.installer').update(plugs, false) else for _, v in ipairs(opt.fargs) do local p = all_plugins[v] @@ -52,7 +52,7 @@ vim.api.nvim_create_user_command('PlugUpdate', function(opt) table.insert(plugs, p) end end - require('plug.installer').update(plugs) + require('plug.installer').update(plugs, true) end local c = require('plug.config') if c.ui == 'default' then diff --git a/bundle/nvim-plug/test/init.lua b/bundle/nvim-plug/test/init.lua index b18d5ce32..ee61b0b38 100644 --- a/bundle/nvim-plug/test/init.lua +++ b/bundle/nvim-plug/test/init.lua @@ -19,19 +19,20 @@ require('plug').setup({ require('plug').add({ { 'wsdjeg/SourceCounter.vim', - cmds = {'SourceCounter'} + cmds = { 'SourceCounter' }, }, { 'wsdjeg/git.vim', - cmds = {'Git'} + cmds = { 'Git' }, }, { 'wsdjeg/JavaUnit.vim', - cmds = {'JavaUnit'} + cmds = { 'JavaUnit' }, }, { 'wsdjeg/vim-async-dict', build = 'cargo build', + frozen = true, }, { 'wsdjeg/scrollbar.vim',