diff --git a/doc/canola.txt b/doc/canola.txt index 14c6655..28ecd11 100644 --- a/doc/canola.txt +++ b/doc/canola.txt @@ -292,6 +292,11 @@ skip_confirm_for_simple_edits *canola.skip_confirm_for_simple_e * contain at most one copy or move * contain at most five creates +skip_confirm_for_delete *canola.skip_confirm_for_delete* + type: `boolean` default: `false` + When this option is `true`, the confirmation popup will be skipped if all pending + actions are deletes. + prompt_save_on_select_new_entry *canola.prompt_save_on_select_new_entry* type: `boolean` default: `true` There are two cases where this option is relevant: diff --git a/doc/upstream.md b/doc/upstream.md index 459e043..bdfe20c 100644 --- a/doc/upstream.md +++ b/doc/upstream.md @@ -88,7 +88,7 @@ Bugs fixed in this fork that remain open upstream. | [#375](https://github.com/stevearc/oil.nvim/issues/375) | open | Highlights for file types and permissions (P2) | | [#380](https://github.com/stevearc/oil.nvim/issues/380) | open | Show file in oil when editing hidden file | | [#382](https://github.com/stevearc/oil.nvim/issues/382) | open | Relative path in window title (P2) | -| [#392](https://github.com/stevearc/oil.nvim/issues/392) | open | Option to skip delete prompt | +| [#392](https://github.com/stevearc/oil.nvim/issues/392) | fixed | Option to skip delete prompt — fixed — `skip_confirm_for_delete` option | | [#393](https://github.com/stevearc/oil.nvim/issues/393) | open | Auto-save new buffer on entry | | [#396](https://github.com/stevearc/oil.nvim/issues/396) | open | Customize preview content (P2) | | [#399](https://github.com/stevearc/oil.nvim/issues/399) | open | Open file without closing Oil (P1) | diff --git a/lua/canola/config.lua b/lua/canola/config.lua index 3790661..12d2751 100644 --- a/lua/canola/config.lua +++ b/lua/canola/config.lua @@ -32,6 +32,7 @@ local default_config = { cleanup_buffers_on_delete = false, -- Skip the confirmation popup for simple operations (:help canola.skip_confirm_for_simple_edits) skip_confirm_for_simple_edits = false, + skip_confirm_for_delete = false, -- Selecting a new/moved/renamed file or directory will prompt you to save changes first -- (:help prompt_save_on_select_new_entry) prompt_save_on_select_new_entry = true, @@ -236,6 +237,7 @@ default_config.view_options.highlight_filename = nil ---@field delete_to_trash boolean ---@field cleanup_buffers_on_delete boolean ---@field skip_confirm_for_simple_edits boolean +---@field skip_confirm_for_delete boolean ---@field prompt_save_on_select_new_entry boolean ---@field cleanup_delay_ms integer ---@field lsp_file_methods canola.LspFileMethods @@ -268,6 +270,7 @@ local M = {} ---@field delete_to_trash? boolean Send deleted files to the trash instead of permanently deleting them (:help canola-trash). ---@field cleanup_buffers_on_delete? boolean Wipe open buffers for files deleted via canola (:help canola.cleanup_buffers_on_delete). ---@field skip_confirm_for_simple_edits? boolean Skip the confirmation popup for simple operations (:help canola.skip_confirm_for_simple_edits). +---@field skip_confirm_for_delete? boolean Skip the confirmation popup when all pending actions are deletes (:help canola.skip_confirm_for_delete). ---@field prompt_save_on_select_new_entry? boolean Selecting a new/moved/renamed file or directory will prompt you to save changes first (:help prompt_save_on_select_new_entry). ---@field cleanup_delay_ms? integer Canola will automatically delete hidden buffers after this delay. You can set the delay to false to disable cleanup entirely. Note that the cleanup process only starts when none of the canola buffers are currently displayed. ---@field lsp_file_methods? canola.SetupLspFileMethods Configure LSP file operation integration. diff --git a/lua/canola/mutator/confirmation.lua b/lua/canola/mutator/confirmation.lua index 9ed6525..b4448ee 100644 --- a/lua/canola/mutator/confirmation.lua +++ b/lua/canola/mutator/confirmation.lua @@ -67,6 +67,19 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb) cb(true) return end + if should_confirm == nil and config.skip_confirm_for_delete then + local all_deletes = true + for _, action in ipairs(actions) do + if action.type ~= 'delete' then + all_deletes = false + break + end + end + if all_deletes then + cb(true) + return + end + end -- Create the buffer local bufnr = vim.api.nvim_create_buf(false, true)