feat: toggle code window from result container in sidebar (#2579)
This commit is contained in:
@@ -541,6 +541,7 @@ M._defaults = {
|
|||||||
edit_user_request = "e",
|
edit_user_request = "e",
|
||||||
switch_windows = "<Tab>",
|
switch_windows = "<Tab>",
|
||||||
reverse_switch_windows = "<S-Tab>",
|
reverse_switch_windows = "<S-Tab>",
|
||||||
|
toggle_code_window = "x",
|
||||||
remove_file = "d",
|
remove_file = "d",
|
||||||
add_file = "@",
|
add_file = "@",
|
||||||
close = { "q" },
|
close = { "q" },
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ Sidebar.__index = Sidebar
|
|||||||
---@field bufnr integer
|
---@field bufnr integer
|
||||||
---@field selection avante.SelectionResult | nil
|
---@field selection avante.SelectionResult | nil
|
||||||
---@field old_winhl string | nil
|
---@field old_winhl string | nil
|
||||||
|
---@field win_width integer | nil
|
||||||
|
|
||||||
---@class avante.Sidebar
|
---@class avante.Sidebar
|
||||||
---@field id integer
|
---@field id integer
|
||||||
@@ -1478,6 +1479,16 @@ function Sidebar:resize()
|
|||||||
vim.defer_fn(function() vim.cmd("AvanteRefresh") end, 200)
|
vim.defer_fn(function() vim.cmd("AvanteRefresh") end, 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Sidebar:toggleCodeWindow()
|
||||||
|
local win_width = api.nvim_win_get_width(self.code.winid)
|
||||||
|
if win_width == 0 then
|
||||||
|
api.nvim_win_set_width(self.code.winid, self.code.win_width)
|
||||||
|
else
|
||||||
|
self.code.win_width = win_width
|
||||||
|
api.nvim_win_set_width(self.code.winid, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Initialize the sidebar instance.
|
--- Initialize the sidebar instance.
|
||||||
--- @return avante.Sidebar The Sidebar instance.
|
--- @return avante.Sidebar The Sidebar instance.
|
||||||
function Sidebar:initialize()
|
function Sidebar:initialize()
|
||||||
@@ -2900,6 +2911,7 @@ function Sidebar:render(opts)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
self.containers.result:map("n", Config.mappings.sidebar.close, function() self:shutdown() end)
|
self.containers.result:map("n", Config.mappings.sidebar.close, function() self:shutdown() end)
|
||||||
|
self.containers.result:map("n", Config.mappings.sidebar.toggle_code_window, function() self:toggleCodeWindow() end)
|
||||||
|
|
||||||
self:create_input_container()
|
self:create_input_container()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user