@ -52,32 +52,6 @@ local get_grep_cmd = function(opts, search_query, no_esc)
return string.format ( ' %s %s %s ' , command , search_query , search_path )
end
local function set_search_header ( opts , type )
if not opts then opts = { } end
if opts.no_header then return opts end
if not opts.cwd_header then opts.cwd_header = " cwd: " end
if not opts.search_header then opts.search_header = " Searching for: " end
local header_str
local cwd_str = opts.cwd and ( " %s %s " ) : format ( opts.cwd_header , opts.cwd )
local search_str = opts.search and # opts.search > 0 and
( " %s %s " ) : format ( opts.search_header , opts.search )
-- 1: only search
-- 2: only cwd
-- otherwise, all
if type == 1 then header_str = search_str or ' '
elseif type == 2 then header_str = cwd_str or ' '
else
header_str = search_str or ' '
if # header_str > 0 and cwd_str and # cwd_str > 0 then
header_str = header_str .. " , "
end
header_str = header_str .. ( cwd_str or ' ' )
end
if not header_str or # header_str == 0 then return opts end
opts.fzf_opts [ ' --header ' ] = vim.fn . shellescape ( header_str )
return opts
end
M.grep = function ( opts )
opts = config.normalize_opts ( opts , config.globals . grep )
@ -101,7 +75,7 @@ M.grep = function(opts)
end ] ]
-- search query in header line
opts = set_search _header( opts )
opts = core.set _header( opts )
-- save the search query so the use can
-- call the same search again
@ -111,18 +85,16 @@ M.grep = function(opts)
local command = get_grep_cmd ( opts , opts.search , no_esc )
opts.fzf_fn = libuv.spawn_nvim_fzf_cmd (
local contents = ( opts.git_icons or opts.file_icons ) and
libuv.spawn_nvim_fzf_cmd (
{ cmd = command , cwd = opts.cwd , pid_cb = opts._pid_cb } ,
function ( x )
return core.make_entry_file ( opts , x )
end )
--[[ opts.cb_selected = function(_, x)
return x
end ] ]
or command
opts = core.set_fzf_line_args ( opts )
core.fzf_files ( opts )
core.fzf_files ( opts , contents )
opts.search = nil
end
@ -151,7 +123,7 @@ M.live_grep = function(opts)
end
-- search query in header line
opts = set_search _header( opts , 2 )
opts = core.set _header( opts , 2 )
opts._reload_command = function ( query )
if query and not ( opts.save_last_search == false ) then
@ -204,7 +176,7 @@ M.live_grep_native = function(opts)
end
-- search query in header line
opts = set_search _header( opts , 2 )
opts = core.set _header( opts , 2 )
-- fzf already adds single quotes around the placeholder when expanding
-- for skim we surround it with double quotes or single quote searches fail