From 9fa2d9e51db957a06031110ee7d4c9f307c5bf5b Mon Sep 17 00:00:00 2001 From: Jae-Won Chung Date: Mon, 10 Mar 2025 03:31:13 -0400 Subject: [PATCH] fix: remove `sidebar.close_from_input` default keybinding (#1536) * Remove 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 --- README.md | 6 ++++++ lua/avante/config.lua | 5 +---- lua/avante/sidebar.lua | 8 ++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3741022..e6cc3b7 100644 --- a/README.md +++ b/README.md @@ -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 = "", reverse_switch_windows = "", + remove_file = "d", + add_file = "@", + close = { "", "q" }, + close_from_input = nil, -- e.g., { normal = "", insert = "" } }, }, hints = { enabled = true }, diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 4edb9ab..56867e0 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -392,10 +392,7 @@ M._defaults = { remove_file = "d", add_file = "@", close = { "", "q" }, - close_from_input = { - normal = "", - insert = "", - }, + close_from_input = nil, -- e.g., { normal = "", insert = "" } }, files = { add_current = "ac", -- Add current buffer to selected files diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index d82390a..b1b72b3 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -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 })