Skip to content

Commit

Permalink
feat(file_selector): command for switching the file picker provider. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
brewinski authored Dec 17, 2024
1 parent 9e0b5bf commit e612ad7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lua/avante/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ local PromptInput = require("avante.prompt_input")
---@field toggle avante.ApiToggle
local M = {}

---@param target_provider FileSelectorProvider
M.switch_file_selector_provider = function(target_provider)
require("avante.config").override({
file_selector = {
provider = target_provider,
},
})
end

---@param target Provider
M.switch_provider = function(target) require("avante.providers").refresh(target) end

Expand Down
2 changes: 1 addition & 1 deletion lua/avante/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ M.defaults = {
negate_patterns = {}, -- negate ignore files matching these.
},
--- @class AvanteFileSelectorConfig
--- @field provider "native" | "fzf" | "telescope"
file_selector = {
--- @alias FileSelectorProvider "native" | "fzf" | "telescope" | string
provider = "native",
-- Options override for custom providers
provider_opts = {},
Expand Down
8 changes: 8 additions & 0 deletions plugin/avante.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ cmd("SwitchProvider", function(opts) require("avante.api").switch_provider(vim.t
return vim.tbl_filter(function(key) return key:find(prefix, 1, true) == 1 end, Config.providers)
end,
})
cmd(
"SwitchFileSelectorProvider",
function(opts) require("avante.api").switch_file_selector_provider(vim.trim(opts.args or "")) end,
{
nargs = 1,
desc = "avante: switch file selector provider",
}
)
cmd("Clear", function(opts)
local arg = vim.trim(opts.args or "")
arg = arg == "" and "history" or arg
Expand Down

0 comments on commit e612ad7

Please sign in to comment.