mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 12:08:33 +00:00
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.
This commit is contained in:
@@ -332,6 +332,22 @@ describe('vim.pack', function()
|
||||
eq({ confirm_msg, 'Proceed? &Yes\n&No', 1, 'Question' }, exec_lua('return _G.confirm_args'))
|
||||
end)
|
||||
|
||||
it('respects `opts.confirm`', function()
|
||||
exec_lua(function()
|
||||
_G.confirm_used = false
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
vim.fn.confirm = function()
|
||||
_G.confirm_used = true
|
||||
return 1
|
||||
end
|
||||
|
||||
vim.pack.add({ repos_src.basic }, { confirm = false })
|
||||
end)
|
||||
|
||||
eq(false, exec_lua('return _G.confirm_used'))
|
||||
eq('basic main', exec_lua('return require("basic")'))
|
||||
end)
|
||||
|
||||
it('installs at proper version', function()
|
||||
local out = exec_lua(function()
|
||||
vim.pack.add({
|
||||
|
Reference in New Issue
Block a user