feat(repo-map): configurable negate patterns (#844)

This commit is contained in:
Christopher Brewin 2024-11-14 19:30:00 +10:00 committed by GitHub
parent fb7567ac24
commit 3abdb69fa2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -212,6 +212,7 @@ M.defaults = {
--- @class AvanteRepoMapConfig
repo_map = {
ignore_patterns = { "%.git", "%.worktree", "__pycache__", "node_modules" }, -- ignore files matching these
negate_patterns = {}, -- negate ignore files matching these.
},
}

View File

@ -48,8 +48,9 @@ end
function RepoMap._build_repo_map(project_root, file_ext)
local output = {}
local gitignore_path = project_root .. "/.gitignore"
local gitignore_patterns, negate_patterns = Utils.parse_gitignore(gitignore_path)
local gitignore_patterns, gitignore_negate_patterns = Utils.parse_gitignore(gitignore_path)
local ignore_patterns = vim.list_extend(gitignore_patterns, Config.repo_map.ignore_patterns)
local negate_patterns = vim.list_extend(gitignore_negate_patterns, Config.repo_map.negate_patterns)
local filepaths = Utils.scan_directory(project_root, ignore_patterns, negate_patterns)
vim.iter(filepaths):each(function(filepath)