Feat: Add hidden to find_files (#340)
This commit is contained in:
@@ -57,6 +57,7 @@ end
|
|||||||
-- Support `find` and maybe let people do other stuff with it as well.
|
-- Support `find` and maybe let people do other stuff with it as well.
|
||||||
files.find_files = function(opts)
|
files.find_files = function(opts)
|
||||||
local find_command = opts.find_command
|
local find_command = opts.find_command
|
||||||
|
local hidden = opts.hidden
|
||||||
local search_dirs = opts.search_dirs
|
local search_dirs = opts.search_dirs
|
||||||
|
|
||||||
if search_dirs then
|
if search_dirs then
|
||||||
@@ -68,6 +69,7 @@ files.find_files = function(opts)
|
|||||||
if not find_command then
|
if not find_command then
|
||||||
if 1 == vim.fn.executable("fd") then
|
if 1 == vim.fn.executable("fd") then
|
||||||
find_command = { 'fd', '--type', 'f' }
|
find_command = { 'fd', '--type', 'f' }
|
||||||
|
if hidden then table.insert(find_command, '--hidden') end
|
||||||
if search_dirs then
|
if search_dirs then
|
||||||
table.insert(find_command, '.')
|
table.insert(find_command, '.')
|
||||||
for _,v in pairs(search_dirs) do
|
for _,v in pairs(search_dirs) do
|
||||||
@@ -76,6 +78,7 @@ files.find_files = function(opts)
|
|||||||
end
|
end
|
||||||
elseif 1 == vim.fn.executable("fdfind") then
|
elseif 1 == vim.fn.executable("fdfind") then
|
||||||
find_command = { 'fdfind', '--type', 'f' }
|
find_command = { 'fdfind', '--type', 'f' }
|
||||||
|
if hidden then table.insert(find_command, '--hidden') end
|
||||||
if search_dirs then
|
if search_dirs then
|
||||||
table.insert(find_command, '.')
|
table.insert(find_command, '.')
|
||||||
for _,v in pairs(search_dirs) do
|
for _,v in pairs(search_dirs) do
|
||||||
@@ -84,6 +87,7 @@ files.find_files = function(opts)
|
|||||||
end
|
end
|
||||||
elseif 1 == vim.fn.executable("rg") then
|
elseif 1 == vim.fn.executable("rg") then
|
||||||
find_command = { 'rg', '--files' }
|
find_command = { 'rg', '--files' }
|
||||||
|
if hidden then table.insert(find_command, '--hidden') end
|
||||||
if search_dirs then
|
if search_dirs then
|
||||||
for _,v in pairs(search_dirs) do
|
for _,v in pairs(search_dirs) do
|
||||||
table.insert(find_command, v)
|
table.insert(find_command, v)
|
||||||
@@ -91,6 +95,7 @@ files.find_files = function(opts)
|
|||||||
end
|
end
|
||||||
elseif 1 == vim.fn.executable("find") then
|
elseif 1 == vim.fn.executable("find") then
|
||||||
find_command = { 'find', '.', '-type', 'f' }
|
find_command = { 'find', '.', '-type', 'f' }
|
||||||
|
if not hidden then vim.tbl_extend("error", find_command, {'-not', '-path', '*/.*'}) end
|
||||||
if search_dirs then
|
if search_dirs then
|
||||||
table.remove(find_command, 2)
|
table.remove(find_command, 2)
|
||||||
for _,v in pairs(search_dirs) do
|
for _,v in pairs(search_dirs) do
|
||||||
|
|||||||
Reference in New Issue
Block a user