diff options
| author | Anirudh Haritas Murali <49116134+anihm136@users.noreply.github.com> | 2020-12-17 02:31:49 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-17 00:01:49 +0300 |
| commit | b5ff9de13d4b15e78e9d3433d6bf085601f62a5d (patch) | |
| tree | 0be4a77baf7a02a5c590557635bea8648529e67c /lua/telescope/builtin/files.lua | |
| parent | 205790285b3e4e933ab85eee62b1b515243a40bc (diff) | |
feat: add search_dirs opt to builtin.find_files to search from multiple dirs (#237)
Diffstat (limited to 'lua/telescope/builtin/files.lua')
| -rw-r--r-- | lua/telescope/builtin/files.lua | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua index c1c947f..1597bc9 100644 --- a/lua/telescope/builtin/files.lua +++ b/lua/telescope/builtin/files.lua @@ -57,16 +57,46 @@ end -- Support `find` and maybe let people do other stuff with it as well. files.find_files = function(opts) local find_command = opts.find_command + local search_dirs = opts.search_dirs + + if search_dirs then + for k,v in pairs(search_dirs) do + search_dirs[k] = vim.fn.expand(v) + end + end if not find_command then if 1 == vim.fn.executable("fd") then find_command = { 'fd', '--type', 'f' } + if search_dirs then + table.insert(find_command, '.') + for _,v in pairs(search_dirs) do + table.insert(find_command, v) + end + end elseif 1 == vim.fn.executable("fdfind") then find_command = { 'fdfind', '--type', 'f' } + if search_dirs then + table.insert(find_command, '.') + for _,v in pairs(search_dirs) do + table.insert(find_command, v) + end + end elseif 1 == vim.fn.executable("rg") then find_command = { 'rg', '--files' } + if search_dirs then + for _,v in pairs(search_dirs) do + table.insert(find_command, v) + end + end elseif 1 == vim.fn.executable("find") then find_command = { 'find', '.', '-type', 'f' } + if search_dirs then + table.remove(find_command, 2) + for _,v in pairs(search_dirs) do + table.insert(find_command, 2, v) + end + end end end |
