feat: add symlink detection
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local uv = vim.loop
|
local uv = vim.loop
|
||||||
-- Remove local config = require('chatgpt_nvim.config') so we don't load config each time
|
|
||||||
-- We'll accept a 'conf' parameter in our functions instead
|
|
||||||
-- local config = require('chatgpt_nvim.config')
|
|
||||||
|
|
||||||
local function load_gitignore_patterns(root, conf)
|
local function load_gitignore_patterns(root, conf)
|
||||||
local gitignore_path = root .. "/.gitignore"
|
local gitignore_path = root .. "/.gitignore"
|
||||||
@@ -80,6 +77,18 @@ local function scandir(dir, ignore_patterns, files, conf)
|
|||||||
table.insert(files, fullpath)
|
table.insert(files, fullpath)
|
||||||
elseif ent.type == "directory" and ent.name ~= ".git" then
|
elseif ent.type == "directory" and ent.name ~= ".git" then
|
||||||
scandir(fullpath, ignore_patterns, files, conf)
|
scandir(fullpath, ignore_patterns, files, conf)
|
||||||
|
elseif ent.type == "link" then
|
||||||
|
local link_target = uv.fs_readlink(fullpath)
|
||||||
|
if link_target then
|
||||||
|
local st = uv.fs_stat(link_target)
|
||||||
|
if st and st.type == "directory" then
|
||||||
|
table.insert(files, fullpath .. " (symlink to directory " .. link_target .. ")")
|
||||||
|
else
|
||||||
|
table.insert(files, fullpath .. " (symlink to file " .. link_target .. ")")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(files, fullpath .. " (symlink)")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -89,7 +98,6 @@ local function scandir(dir, ignore_patterns, files, conf)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.get_project_files(directories, conf)
|
function M.get_project_files(directories, conf)
|
||||||
-- conf is passed in from outside so we don't load config repeatedly
|
|
||||||
local root = vim.fn.getcwd()
|
local root = vim.fn.getcwd()
|
||||||
local ignore_patterns = load_gitignore_patterns(root, conf)
|
local ignore_patterns = load_gitignore_patterns(root, conf)
|
||||||
local all_files = {}
|
local all_files = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user