|
|
@ -48,15 +48,32 @@ local get_grep_cmd = function(opts, search_query, no_esc)
|
|
|
|
return string.format('%s %s %s', command, search_query, search_path)
|
|
|
|
return string.format('%s %s %s', command, search_query, search_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function set_search_header(opts)
|
|
|
|
local function set_search_header(opts, type)
|
|
|
|
if not opts then opts = {} end
|
|
|
|
if not opts then opts = {} end
|
|
|
|
if opts.no_header then return opts end
|
|
|
|
if opts.no_header then return opts end
|
|
|
|
if not opts.search or #opts.search==0 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
|
|
|
|
if not opts.search_header then opts.search_header = "Searching for:" end
|
|
|
|
opts._fzf_cli_args = opts._fzf_cli_args or ''
|
|
|
|
local header_str
|
|
|
|
opts._fzf_cli_args = string.format([[%s --header=%s]],
|
|
|
|
local cwd_str = opts.cwd and ("%s %s"):format(opts.cwd_header, opts.cwd)
|
|
|
|
opts._fzf_cli_args,
|
|
|
|
local search_str = opts.search and #opts.search > 0 and
|
|
|
|
vim.fn.shellescape(("%s %s"):format(opts.search_header, opts.search)))
|
|
|
|
("%s %s"):format(opts.search_header, opts.search)
|
|
|
|
|
|
|
|
-- 1: only search
|
|
|
|
|
|
|
|
-- 2: only cwd
|
|
|
|
|
|
|
|
-- otherwise, all
|
|
|
|
|
|
|
|
if type == 1 and search_str then header_str = search_str
|
|
|
|
|
|
|
|
elseif type == 2 and cwd_str then header_str = cwd_str
|
|
|
|
|
|
|
|
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 then return opts end
|
|
|
|
|
|
|
|
opts._fzf_header_args = opts._fzf_header_args or ''
|
|
|
|
|
|
|
|
opts._fzf_header_args = string.format([[%s --header=%s ]],
|
|
|
|
|
|
|
|
opts._fzf_header_args,
|
|
|
|
|
|
|
|
vim.fn.shellescape(header_str))
|
|
|
|
return opts
|
|
|
|
return opts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -132,6 +149,9 @@ M.live_grep = function(opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- search query in header line
|
|
|
|
|
|
|
|
opts = set_search_header(opts, 2)
|
|
|
|
|
|
|
|
|
|
|
|
opts._cb_live_cmd = function(query)
|
|
|
|
opts._cb_live_cmd = function(query)
|
|
|
|
if query and #query>0 and not opts.do_not_save_last_search then
|
|
|
|
if query and #query>0 and not opts.do_not_save_last_search then
|
|
|
|
last_search = {}
|
|
|
|
last_search = {}
|
|
|
@ -174,6 +194,9 @@ M.live_grep_native = function(opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- search query in header line
|
|
|
|
|
|
|
|
opts = set_search_header(opts, 2)
|
|
|
|
|
|
|
|
|
|
|
|
-- fzf already adds single quotes around the placeholder when expanding
|
|
|
|
-- fzf already adds single quotes around the placeholder when expanding
|
|
|
|
-- for skim we surround it with double quotes or single quote searches fail
|
|
|
|
-- for skim we surround it with double quotes or single quote searches fail
|
|
|
|
local placeholder = utils._if(opts._is_skim, '"{}"', '{q}')
|
|
|
|
local placeholder = utils._if(opts._is_skim, '"{}"', '{q}')
|
|
|
|