diff --git a/lua/oil/mutator/preview.lua b/lua/oil/mutator/preview.lua index 5e41898..64cd520 100644 --- a/lua/oil/mutator/preview.lua +++ b/lua/oil/mutator/preview.lua @@ -45,11 +45,12 @@ end ---@param bufnr integer ---@param lines string[] local function render_lines(winid, bufnr, lines) - util.render_text( - bufnr, - lines, - { v_align = "top", h_align = "left", winid = winid, actions = { "[O]k", "[C]ancel" } } - ) + util.render_text(bufnr, lines, { + v_align = "top", + h_align = "left", + winid = winid, + actions = { "[Y]es", "[N]o" }, + }) end ---@param actions oil.Action[] @@ -165,17 +166,22 @@ M.show = vim.schedule_wrap(function(actions, should_confirm, cb) end, }) ) - for _, cancel_key in ipairs({ "q", "C", "c", "", "" }) do + + -- We used to use [C]ancel to cancel, so preserve the old keymap + local cancel_keys = { "n", "N", "c", "C", "q", "", "" } + for _, cancel_key in ipairs(cancel_keys) do vim.keymap.set("n", cancel_key, function() cancel() end, { buffer = bufnr, nowait = true }) end - vim.keymap.set("n", "O", function() - confirm() - end, { buffer = bufnr }) - vim.keymap.set("n", "o", function() - confirm() - end, { buffer = bufnr }) + + -- We used to use [O]k to confirm, so preserve the old keymap + local confirm_keys = { "y", "Y", "o", "O" } + for _, confirm_key in ipairs(confirm_keys) do + vim.keymap.set("n", confirm_key, function() + confirm() + end, { buffer = bufnr, nowait = true }) + end end) return M