feat: better debug logging for ignored files

This commit is contained in:
2024-12-14 13:04:29 +01:00
parent e97aa81d8f
commit 63832ae0c3

View File

@@ -31,8 +31,12 @@ local function load_gitignore_patterns(root)
end end
local function should_ignore_file(file, ignore_patterns) local function should_ignore_file(file, ignore_patterns)
local conf = config.load()
for _, pattern in ipairs(ignore_patterns) do for _, pattern in ipairs(ignore_patterns) do
if file:find(pattern, 1, true) then if file:find(pattern, 1, true) then
if conf.debug then
vim.api.nvim_out_write("[chatgpt_nvim:context] Ignoring file/dir: " .. file .. " (matched pattern: " .. pattern .. ")\n")
end
return true return true
end end
end end
@@ -80,10 +84,6 @@ local function scandir(dir, ignore_patterns, files)
elseif ent.type == "directory" and ent.name ~= ".git" then elseif ent.type == "directory" and ent.name ~= ".git" then
scandir(fullpath, ignore_patterns, files) scandir(fullpath, ignore_patterns, files)
end end
else
if conf.debug then
vim.api.nvim_out_write("[chatgpt_nvim:context] Ignoring file/dir: " .. fullpath .. "\n")
end
end end
end end
end end