fix: remove sidebar.close_from_input default keybinding (#1536)

* Remove <c-d> from default insert mode keybinding

* Check `close_from_input ~= nil` before keymap

* Default `close_from_input` to `nil`

* Update README.md keybinding defaults

* Try to pass type check
This commit is contained in:
Jae-Won Chung
2025-03-10 03:31:13 -04:00
committed by GitHub
parent f9025ff415
commit 9fa2d9e51d
3 changed files with 13 additions and 6 deletions

View File

@@ -349,8 +349,14 @@ _See [config.lua#L9](./lua/avante/config.lua) for the full config_
sidebar = {
apply_all = "A",
apply_cursor = "a",
retry_user_request = "r",
edit_user_request = "e",
switch_windows = "<Tab>",
reverse_switch_windows = "<S-Tab>",
remove_file = "d",
add_file = "@",
close = { "<Esc>", "q" },
close_from_input = nil, -- e.g., { normal = "<Esc>", insert = "<C-d>" }
},
},
hints = { enabled = true },

View File

@@ -392,10 +392,7 @@ M._defaults = {
remove_file = "d",
add_file = "@",
close = { "<Esc>", "q" },
close_from_input = {
normal = "<Esc>",
insert = "<C-d>",
},
close_from_input = nil, -- e.g., { normal = "<Esc>", insert = "<C-d>" }
},
files = {
add_current = "<leader>ac", -- Add current buffer to selected files

View File

@@ -2719,8 +2719,12 @@ function Sidebar:create_input_container(opts)
self.input_container:map("n", Config.mappings.submit.normal, on_submit)
self.input_container:map("i", Config.mappings.submit.insert, on_submit)
self.input_container:map("n", Config.mappings.sidebar.close_from_input.normal, function() self:shutdown() end)
self.input_container:map("i", Config.mappings.sidebar.close_from_input.insert, function() self:shutdown() end)
local close_from_input = Config.mappings.sidebar.close_from_input
if close_from_input ~= nil then
self.input_container:map("n", close_from_input.normal, function() self:shutdown() end)
self.input_container:map("i", close_from_input.insert, function() self:shutdown() end)
end
api.nvim_set_option_value("filetype", "AvanteInput", { buf = self.input_container.bufnr })