diff --git a/lua/avante/api.lua b/lua/avante/api.lua index 9ac892b..fc4496b 100644 --- a/lua/avante/api.lua +++ b/lua/avante/api.lua @@ -237,6 +237,16 @@ function M.select_history() end) end +function M.add_buffer_files() + local sidebar = require("avante").get() + if not sidebar then + require("avante.api").ask() + sidebar = require("avante").get() + end + if not sidebar:is_open() then sidebar:open({}) end + sidebar.file_selector:add_buffer_files() +end + function M.stop() require("avante.llm").cancel_inflight_request() end return setmetatable(M, { diff --git a/lua/avante/config.lua b/lua/avante/config.lua index aef2f36..0675a37 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -416,6 +416,7 @@ M._defaults = { }, files = { add_current = "ac", -- Add current buffer to selected files + add_all_buffers = "aB", -- Add all buffer files to selected files }, select_model = "a?", -- Select model command select_history = "ah", -- Select history command diff --git a/lua/avante/file_selector.lua b/lua/avante/file_selector.lua index f26e505..c5468ab 100644 --- a/lua/avante/file_selector.lua +++ b/lua/avante/file_selector.lua @@ -77,7 +77,7 @@ end function FileSelector:new(id) return setmetatable({ id = id, - selected_files = {}, + selected_filepaths = {}, event_handlers = {}, }, { __index = self }) end diff --git a/lua/avante/init.lua b/lua/avante/init.lua index c8783e0..3b9bbb3 100644 --- a/lua/avante/init.lua +++ b/lua/avante/init.lua @@ -149,6 +149,13 @@ function H.keymaps() function() require("avante.api").select_history() end, { desc = "avante: select history" } ) + + Utils.safe_keymap_set( + "n", + Config.mappings.files.add_all_buffers, + function() require("avante.api").add_buffer_files() end, + { desc = "avante: add all open buffers" } + ) end if Config.behaviour.auto_suggestions then