feat: add mappings to toggle code window from input in sidebar (#2591)

This commit is contained in:
brook hong
2025-08-08 20:11:06 +08:00
committed by GitHub
parent 2fc63d4128
commit 5a4ed4ac92
2 changed files with 20 additions and 0 deletions

View File

@@ -548,6 +548,9 @@ M._defaults = {
---@alias AvanteCloseFromInput { normal: string | nil, insert: string | nil }
---@type AvanteCloseFromInput | nil
close_from_input = nil, -- e.g., { normal = "<Esc>", insert = "<C-d>" }
---@alias AvanteToggleCodeWindowFromInput { normal: string | nil, insert: string | nil }
---@type AvanteToggleCodeWindowFromInput | nil
toggle_code_window_from_input = nil, -- e.g., { normal = "x", insert = "<C-;>" }
},
files = {
add_current = "<leader>ac", -- Add current buffer to selected files

View File

@@ -2729,6 +2729,23 @@ function Sidebar:create_input_container()
end
end
if Config.mappings.sidebar.toggle_code_window_from_input ~= nil then
if Config.mappings.sidebar.toggle_code_window_from_input.normal ~= nil then
self.containers.input:map(
"n",
Config.mappings.sidebar.toggle_code_window_from_input.normal,
function() self:toggleCodeWindow() end
)
end
if Config.mappings.sidebar.toggle_code_window_from_input.insert ~= nil then
self.containers.input:map(
"i",
Config.mappings.sidebar.toggle_code_window_from_input.insert,
function() self:toggleCodeWindow() end
)
end
end
api.nvim_set_option_value("filetype", "AvanteInput", { buf = self.containers.input.bufnr })
-- Setup completion