refactor: preview window uses Yes/No instead of Ok/Cancel (#344)
NOTE: the `o` and `c` keymaps will continue to work. This only changes the text labels and adds new keymaps for `y` and `n`. * chore: replace ok and cancel with yes and no in confirmation window * chore: allow to configure labels and keymaps for confirmation window * chore: remove potential duplicate cancel keymaps * chore: update README and oil.txt * chore: nowait on confirm mappings and cleanup * refactor: fully transition to yes/no * move the config from under the `confirmation` key to the `preview` key, which is already in use for customizing the window * fully default to yes/no, keeping the o/c keybindings for backwards compatibility * make all of the `cancel` keybindings explicit (q, C-c, esc) * more dynamically choose highlighting of the action labels * refactor: just use yes/no and abandon configuration --------- Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
This commit is contained in:
parent
752563c59d
commit
010b44a79d
1 changed files with 18 additions and 12 deletions
|
|
@ -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", "<C-c>", "<Esc>" }) do
|
||||
|
||||
-- We used to use [C]ancel to cancel, so preserve the old keymap
|
||||
local cancel_keys = { "n", "N", "c", "C", "q", "<C-c>", "<Esc>" }
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue