feat: respect git ignore for autosuggestions (#994)

This commit is contained in:
Ethan Howard
2025-01-11 15:00:19 +00:00
committed by GitHub
parent 5c1b9d5463
commit c3e7ba0be0
3 changed files with 18 additions and 2 deletions

View File

@@ -633,7 +633,7 @@ function M.parse_gitignore(gitignore_path)
return ignore_patterns, negate_patterns
end
local function is_ignored(file, ignore_patterns, negate_patterns)
function M.is_ignored(file, ignore_patterns, negate_patterns)
for _, pattern in ipairs(negate_patterns) do
if file:match(pattern) then return false end
end
@@ -657,7 +657,7 @@ function M.scan_directory(directory, ignore_patterns, negate_patterns)
if type == "directory" then
vim.list_extend(files, M.scan_directory(full_path, ignore_patterns, negate_patterns))
elseif type == "file" then
if not is_ignored(full_path, ignore_patterns, negate_patterns) then table.insert(files, full_path) end
if not M.is_ignored(full_path, ignore_patterns, negate_patterns) then table.insert(files, full_path) end
end
end