improve: support to customize the keymaps for cancelling the editing (#1730)
* improve: support to customize the keymaps for cancelling the editing * docs: update README
This commit is contained in:
@@ -366,6 +366,10 @@ _See [config.lua#L9](./lua/avante/config.lua) for the full config_
|
|||||||
normal = "<CR>",
|
normal = "<CR>",
|
||||||
insert = "<C-s>",
|
insert = "<C-s>",
|
||||||
},
|
},
|
||||||
|
cancel = {
|
||||||
|
normal = { "<C-c>", "<Esc>", "q" },
|
||||||
|
insert = { "<C-c>" },
|
||||||
|
},
|
||||||
sidebar = {
|
sidebar = {
|
||||||
apply_all = "A",
|
apply_all = "A",
|
||||||
apply_cursor = "a",
|
apply_cursor = "a",
|
||||||
|
|||||||
@@ -383,6 +383,10 @@ M._defaults = {
|
|||||||
normal = "<CR>",
|
normal = "<CR>",
|
||||||
insert = "<C-s>",
|
insert = "<C-s>",
|
||||||
},
|
},
|
||||||
|
cancel = {
|
||||||
|
normal = { "<C-c>", "<Esc>", "q" },
|
||||||
|
insert = { "<C-c>" },
|
||||||
|
},
|
||||||
-- NOTE: The following will be safely set by avante.nvim
|
-- NOTE: The following will be safely set by avante.nvim
|
||||||
ask = "<leader>aa",
|
ask = "<leader>aa",
|
||||||
edit = "<leader>ae",
|
edit = "<leader>ae",
|
||||||
|
|||||||
@@ -268,8 +268,12 @@ function PromptInput:setup_keymaps()
|
|||||||
{ buffer = bufnr, noremap = true, silent = true }
|
{ buffer = bufnr, noremap = true, silent = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
vim.keymap.set("n", "<Esc>", function() self:cancel() end, { buffer = bufnr })
|
for _, key in ipairs(Config.mappings.cancel.normal) do
|
||||||
vim.keymap.set("n", "q", function() self:cancel() end, { buffer = bufnr })
|
vim.keymap.set("n", key, function() self:cancel() end, { buffer = bufnr })
|
||||||
|
end
|
||||||
|
for _, key in ipairs(Config.mappings.cancel.insert) do
|
||||||
|
vim.keymap.set("i", key, function() self:cancel() end, { buffer = bufnr })
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function PromptInput:setup_autocmds()
|
function PromptInput:setup_autocmds()
|
||||||
|
|||||||
Reference in New Issue
Block a user