diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 8b3adbe..c499157 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -509,6 +509,12 @@ M._defaults = { }, select_model = "a?", -- Select model command select_history = "ah", -- Select history command + confirm = { + focus_window = "f", + code = "c", + resp = "r", + input = "i", + }, }, windows = { ---@alias AvantePosition "right" | "left" | "top" | "bottom" | "smart" diff --git a/lua/avante/ui/confirm.lua b/lua/avante/ui/confirm.lua index 9955a9e..7245aef 100644 --- a/lua/avante/ui/confirm.lua +++ b/lua/avante/ui/confirm.lua @@ -46,18 +46,17 @@ function M:open() local commentfg = Highlights.AVANTE_COMMENT_FG - -- local keybindings_content = "f: focus; c: code; r: resp; i: input" local keybindings_line = Line:new({ - { " f ", "visual" }, + { " " .. Config.mappings.confirm.focus_window .. " ", "visual" }, { " - focus ", commentfg }, { " " }, - { " c ", "visual" }, + { " " .. Config.mappings.confirm.code .. " ", "visual" }, { " - code ", commentfg }, { " " }, - { " r ", "visual" }, + { " " .. Config.mappings.confirm.resp .. " ", "visual" }, { " - resp ", commentfg }, { " " }, - { " i ", "visual" }, + { " " .. Config.mappings.confirm.input .. " ", "visual" }, { " - input ", commentfg }, { " " }, }) @@ -176,7 +175,7 @@ function M:open() prompt_input:open() end - vim.keymap.set("n", "c", function() + vim.keymap.set("n", Config.mappings.confirm.code, function() local sidebar = require("avante").get() if not sidebar then return end if sidebar.code.winid and vim.api.nvim_win_is_valid(sidebar.code.winid) then @@ -184,7 +183,7 @@ function M:open() end end, { buffer = popup.bufnr }) - vim.keymap.set("n", "r", function() + vim.keymap.set("n", Config.mappings.confirm.resp, function() local sidebar = require("avante").get() if not sidebar then return end if sidebar.winids.result_container and vim.api.nvim_win_is_valid(sidebar.winids.result_container) then @@ -192,7 +191,7 @@ function M:open() end end, { buffer = popup.bufnr }) - vim.keymap.set("n", "i", function() + vim.keymap.set("n", Config.mappings.confirm.input, function() local sidebar = require("avante").get() if not sidebar then return end if sidebar.winids.input_container and vim.api.nvim_win_is_valid(sidebar.winids.input_container) then @@ -340,10 +339,10 @@ function M:window_focus_handler() end function M:bind_window_focus_keymaps() - vim.keymap.set({ "n", "i" }, "f", function() self:window_focus_handler() end) + vim.keymap.set({ "n", "i" }, Config.mappings.confirm.focus_window, function() self:window_focus_handler() end) end -function M:unbind_window_focus_keymaps() pcall(vim.keymap.del, { "n", "i" }, "f") end +function M:unbind_window_focus_keymaps() pcall(vim.keymap.del, { "n", "i" }, Config.mappings.confirm.focus_window) end function M:cancel() self.callback("no", "cancel")