aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-08-09 17:28:14 +0300
committerEvgeni Chasnovski <evgeni.chasnovski@gmail.com>2025-08-09 17:54:39 +0300
commitacff86601efd3923fdb1ef4088574fff6befbe37 (patch)
treef97c65e1700a52438e7815f66031e600cc4eb7b7 /runtime/lua/vim
parentdd828690c747d0adf19b9f455e0b4cfe2d1ae954 (diff)
downloadrneovim-acff86601efd3923fdb1ef4088574fff6befbe37.tar.gz
rneovim-acff86601efd3923fdb1ef4088574fff6befbe37.tar.bz2
rneovim-acff86601efd3923fdb1ef4088574fff6befbe37.zip
feat(pack): allow skip install confirmation in `add()`
Problem: No way to skip install confirmation in `add()`. Having install confirmation by default is a more secure design. However, users are usually aware of the fact that plugin will be installed and there is currently no way to skip confirmation. Plus it can introduce inconvenience on the clean config initialization if it is modularized with many `vim.pack.add()` calls (leads to confirming installation many times in a row). Solution: Add `opts.confirm` option that can skip install confirmation.
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/pack.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua
index dbd426d37d..da4456d399 100644
--- a/runtime/lua/vim/pack.lua
+++ b/runtime/lua/vim/pack.lua
@@ -562,9 +562,9 @@ local function checkout(p, timestamp, skip_same_sha)
end
--- @param plug_list vim.pack.Plug[]
-local function install_list(plug_list)
+local function install_list(plug_list, confirm)
-- Get user confirmation to install plugins
- if not confirm_install(plug_list) then
+ if confirm and not confirm_install(plug_list) then
for _, p in ipairs(plug_list) do
p.info.err = 'Installation was not confirmed'
end
@@ -681,6 +681,8 @@ end
--- If function, called with plugin data and is fully responsible for loading plugin.
--- Default `false` during startup and `true` afterwards.
--- @field load? boolean|fun(plug_data: {spec: vim.pack.Spec, path: string})
+---
+--- @field confirm? boolean Whether to ask user to confirm initial install. Default `true`.
--- Add plugin to current session
---
@@ -705,7 +707,7 @@ end
--- @param opts? vim.pack.keyset.add
function M.add(specs, opts)
vim.validate('specs', specs, vim.islist, false, 'list')
- opts = vim.tbl_extend('force', { load = vim.v.vim_did_enter == 1 }, opts or {})
+ opts = vim.tbl_extend('force', { load = vim.v.vim_did_enter == 1, confirm = true }, opts or {})
vim.validate('opts', opts, 'table')
--- @type vim.pack.Plug[]
@@ -720,7 +722,7 @@ function M.add(specs, opts)
if #plugs_to_install > 0 then
git_ensure_exec()
- install_list(plugs_to_install)
+ install_list(plugs_to_install, opts.confirm)
end
-- Register and load those actually on disk while collecting errors