From cee31ebb7f0498f526089b94aff0bb832417fc75 Mon Sep 17 00:00:00 2001 From: doodleEsc <1056315827@qq.com> Date: Wed, 30 Apr 2025 03:12:45 +0800 Subject: [PATCH] feat: allow excluding filetypes from selector autolaunch. (#1937) Co-authored-by: doodleEsc Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> --- lua/avante/config.lua | 1 + lua/avante/sidebar.lua | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lua/avante/config.lua b/lua/avante/config.lua index 33d4b1c..4f2392b 100644 --- a/lua/avante/config.lua +++ b/lua/avante/config.lua @@ -522,6 +522,7 @@ M._defaults = { ---@alias avante.SelectorProvider "native" | "fzf_lua" | "mini_pick" | "snacks" | "telescope" | fun(selector: avante.ui.Selector): nil provider = "native", provider_opts = {}, + exclude_auto_select = {}, -- List of items to exclude from auto selection }, suggestion = { debounce = 600, diff --git a/lua/avante/sidebar.lua b/lua/avante/sidebar.lua index 77e7baf..1083f12 100644 --- a/lua/avante/sidebar.lua +++ b/lua/avante/sidebar.lua @@ -1548,6 +1548,10 @@ function Sidebar:initialize() if not self.code.bufnr or not api.nvim_buf_is_valid(self.code.bufnr) then return self end + -- check if the filetype of self.code.bufnr is disabled + local buf_ft = api.nvim_get_option_value("filetype", { buf = self.code.bufnr }) + if vim.list_contains(Config.selector.exclude_auto_select, buf_ft) then return self end + local buf_path = api.nvim_buf_get_name(self.code.bufnr) -- if the filepath is outside of the current working directory then we want the absolute path local filepath = Utils.file.is_in_cwd(buf_path) and Utils.relative_path(buf_path) or buf_path