diff --git a/README.md b/README.md index 45d26fc..b2e888d 100644 --- a/README.md +++ b/README.md @@ -366,6 +366,10 @@ _See [config.lua#L9](./lua/avante/config.lua) for the full config_ normal = "", insert = "", }, + cancel = { + normal = { "", "", "q" }, + insert = { "" }, + }, sidebar = { apply_all = "A", apply_cursor = "a", diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 48d8663..a9c2bc3 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -383,6 +383,10 @@ M._defaults = { normal = "", insert = "", }, + cancel = { + normal = { "", "", "q" }, + insert = { "" }, + }, -- NOTE: The following will be safely set by avante.nvim ask = "aa", edit = "ae", diff --git a/lua/avante/ui/prompt_input.lua b/lua/avante/ui/prompt_input.lua index 54f3a9b..c87de0e 100644 --- a/lua/avante/ui/prompt_input.lua +++ b/lua/avante/ui/prompt_input.lua @@ -268,8 +268,12 @@ function PromptInput:setup_keymaps() { buffer = bufnr, noremap = true, silent = true } ) - vim.keymap.set("n", "", function() self:cancel() end, { buffer = bufnr }) - vim.keymap.set("n", "q", function() self:cancel() end, { buffer = bufnr }) + for _, key in ipairs(Config.mappings.cancel.normal) do + 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 function PromptInput:setup_autocmds()