better cwd param handling for files|files_resume

main
bhagwan 3 years ago
parent 2dd5046455
commit f3f373beaf

@ -127,7 +127,7 @@ M.globals.files = {
color_icons = true,
git_icons = true,
git_status_cmd = "git status -s",
find_opts = "-type f -printf '%P\n'",
find_opts = [[-type f -not -path '*/\.git/*' -printf '%P\n']],
fd_opts =
[[--color never --type f --hidden --follow ]] ..
[[--exclude .git --exclude node_modules --exclude '*.pyc']],

@ -18,17 +18,9 @@ local get_files_cmd = function(opts)
end
local command = nil
if vim.fn.executable("fd") == 1 then
if not opts.cwd or #opts.cwd == 0 then
command = string.format('fd %s', opts.fd_opts)
else
command = string.format('fd %s . %s', opts.fd_opts,
vim.fn.shellescape(vim.fn.expand(opts.cwd)))
end
command = string.format('fd %s', opts.fd_opts)
else
command = string.format('find -L %s %s',
utils._if(opts.cwd and #opts.cwd>0,
vim.fn.shellescape(vim.fn.expand(opts.cwd)), '.'),
opts.find_opts)
command = string.format('find -L . %s', opts.find_opts)
end
return command
end
@ -40,7 +32,8 @@ M.files = function(opts)
local command = get_files_cmd(opts)
opts.fzf_fn = fzf_helpers.cmd_line_transformer(command,
opts.fzf_fn = fzf_helpers.cmd_line_transformer(
{cmd = command, cwd = opts.cwd},
function(x)
return core.make_entry_file(opts, x)
end)
@ -68,7 +61,8 @@ M.files_resume = function(opts)
opts._fzf_cli_args = ('--query="%s" --bind=change:execute-silent:%s'):
format(last_query, vim.fn.shellescape(raw_act))
opts.fzf_fn = fzf_helpers.cmd_line_transformer(command,
opts.fzf_fn = fzf_helpers.cmd_line_transformer(
{cmd = command, cwd = opts.cwd},
function(x)
return core.make_entry_file(opts, x)
end)

Loading…
Cancel
Save