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 diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 0a12764..04d5f3d 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -77,7 +77,8 @@ do mt_file_entry.cwd = cwd mt_file_entry.display = function(entry) - local display, hl_group = entry.value + local hl_group + local display = path.make_relative(entry.value, cwd) if shorten_path then display = utils.path_shorten(display) end @@ -96,7 +97,11 @@ do if raw then return raw end if k == "path" then - return t.cwd .. path.separator .. t.value + local retpath = t.cwd .. path.separator .. t.value + if not vim.loop.fs_access(retpath, "R", nil) then + retpath = t.value + end + return retpath end return rawget(t, rawget(lookup_keys, k))