From 56951378f10b25f8bb0f5bb516b8d778a1e498a7 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Thu, 11 Sep 2025 15:44:14 +0200 Subject: [PATCH] feat: include hidden files when scanning directories (#2700) --- lua/avante/utils/init.lua | 40 ++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/lua/avante/utils/init.lua b/lua/avante/utils/init.lua index 1a1cf38..355fe24 100644 --- a/lua/avante/utils/init.lua +++ b/lua/avante/utils/init.lua @@ -896,21 +896,43 @@ function M.scan_directory(options) local cmd_supports_max_depth = true local cmd = (function() if vim.fn.executable("rg") == 1 then - local cmd = { "rg", "--files", "--color", "never", "--no-require-git", "--no-ignore-parent" } + local cmd = { + "rg", + "--files", + "--color", + "never", + "--no-require-git", + "--no-ignore-parent", + "--hidden", + "--glob", + "!.git/", + } + if options.max_depth ~= nil then vim.list_extend(cmd, { "--max-depth", options.max_depth }) end table.insert(cmd, options.directory) + return cmd end - if vim.fn.executable("fd") == 1 then - local cmd = { "fd", "--type", "f", "--color", "never", "--no-require-git" } - if options.max_depth ~= nil then vim.list_extend(cmd, { "--max-depth", options.max_depth }) end - vim.list_extend(cmd, { "--base-directory", options.directory }) - return cmd - end - if vim.fn.executable("fdfind") == 1 then - local cmd = { "fdfind", "--type", "f", "--color", "never", "--no-require-git" } + + -- fd is called 'fdfind' on Debian/Ubuntu due to naming conflicts + local fd_executable = vim.fn.executable("fd") == 1 and "fd" + or (vim.fn.executable("fdfind") == 1 and "fdfind" or nil) + if fd_executable then + local cmd = { + fd_executable, + "--type", + "f", + "--color", + "never", + "--no-require-git", + "--hidden", + "--exclude", + ".git", + } + if options.max_depth ~= nil then vim.list_extend(cmd, { "--max-depth", options.max_depth }) end vim.list_extend(cmd, { "--base-directory", options.directory }) + return cmd end end)()