1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-14 06:18:00 +08:00

feat(nvim-plug): add frozen option

This commit is contained in:
Eric Wong 2025-02-07 21:22:07 +08:00
parent 68b2146c17
commit 0f9396a709
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
5 changed files with 16 additions and 10 deletions

View File

@ -88,6 +88,7 @@ require('plug').add({
| `type` | `string`, plugin type including `color`, `plugin` | | `type` | `string`, plugin type including `color`, `plugin` |
| `build` | `string` or `table<string>`, executed by [job](https://spacevim.org/api/job/) api | | `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 | | `enabled` | `boolean` or `function` evaluated when startup, when it is false, plugin will be skiped |
| `frozen` | update only when specific with `PlugUpdate name` |
## Commands ## Commands

View File

@ -134,14 +134,17 @@ local function install_plugin(plugSpec)
end end
--- @param plugSpec PluginSpec --- @param plugSpec PluginSpec
local function update_plugin(plugSpec) local function update_plugin(plugSpec, force)
if processes >= config.max_processes then if processes >= config.max_processes then
table.insert(updating_queue, plugSpec) table.insert(updating_queue, {plugSpec, force})
return return
elseif vim.fn.isdirectory(plugSpec.path) ~= 1 then elseif vim.fn.isdirectory(plugSpec.path) ~= 1 then
-- if the directory does not exist, return failed -- if the directory does not exist, return failed
on_uidate(plugSpec.name, { command = 'pull', pull_done = false }) on_uidate(plugSpec.name, { command = 'pull', pull_done = false })
return return
elseif plugSpec.frozen and not force then
on_uidate(plugSpec.name, { command = 'pull', pull_done = true })
return
end end
local cmd = { 'git', 'pull', '--progress' } local cmd = { 'git', 'pull', '--progress' }
on_uidate(plugSpec.name, { command = 'pull', pull_process = '' }) on_uidate(plugSpec.name, { command = 'pull', pull_process = '' })
@ -170,7 +173,7 @@ local function update_plugin(plugSpec)
end end
processes = processes - 1 processes = processes - 1
if #updating_queue > 0 then if #updating_queue > 0 then
update_plugin(table.remove(updating_queue, 1)) update_plugin(unpack(table.remove(updating_queue, 1)))
end end
end, end,
cwd = plugSpec.path, cwd = plugSpec.path,
@ -193,9 +196,9 @@ M.install = function(plugSpecs)
end end
end end
M.update = function(plugSpecs) M.update = function(plugSpecs, force)
for _, v in ipairs(plugSpecs) do for _, v in ipairs(plugSpecs) do
update_plugin(v) update_plugin(v, force)
end end
end end

View File

@ -22,6 +22,7 @@ local config = require('plug.config')
--- @field build string|table<string> --- @field build string|table<string>
--- @field is_local boolean true for local plugin --- @field is_local boolean true for local plugin
--- @field when boolean|string|function --- @field when boolean|string|function
--- @field frozen boolean
local function is_local_plugin(plugSpec) local function is_local_plugin(plugSpec)
if plugSpec.is_local or vim.fn.isdirectory(plugSpec[1]) == 1 then if plugSpec.is_local or vim.fn.isdirectory(plugSpec[1]) == 1 then

View File

@ -44,7 +44,7 @@ vim.api.nvim_create_user_command('PlugUpdate', function(opt)
for _, v in pairs(all_plugins) do for _, v in pairs(all_plugins) do
table.insert(plugs, v) table.insert(plugs, v)
end end
require('plug.installer').update(plugs) require('plug.installer').update(plugs, false)
else else
for _, v in ipairs(opt.fargs) do for _, v in ipairs(opt.fargs) do
local p = all_plugins[v] local p = all_plugins[v]
@ -52,7 +52,7 @@ vim.api.nvim_create_user_command('PlugUpdate', function(opt)
table.insert(plugs, p) table.insert(plugs, p)
end end
end end
require('plug.installer').update(plugs) require('plug.installer').update(plugs, true)
end end
local c = require('plug.config') local c = require('plug.config')
if c.ui == 'default' then if c.ui == 'default' then

View File

@ -19,19 +19,20 @@ require('plug').setup({
require('plug').add({ require('plug').add({
{ {
'wsdjeg/SourceCounter.vim', 'wsdjeg/SourceCounter.vim',
cmds = {'SourceCounter'} cmds = { 'SourceCounter' },
}, },
{ {
'wsdjeg/git.vim', 'wsdjeg/git.vim',
cmds = {'Git'} cmds = { 'Git' },
}, },
{ {
'wsdjeg/JavaUnit.vim', 'wsdjeg/JavaUnit.vim',
cmds = {'JavaUnit'} cmds = { 'JavaUnit' },
}, },
{ {
'wsdjeg/vim-async-dict', 'wsdjeg/vim-async-dict',
build = 'cargo build', build = 'cargo build',
frozen = true,
}, },
{ {
'wsdjeg/scrollbar.vim', 'wsdjeg/scrollbar.vim',