Skip to content

Commit a33d382

Browse files
committed
feat: custom fn_transform_cmd (closes #1927)
Enables custom command building, for example git grep with glob: ```lua require("fzf-lua").live_grep({ cmd = "git grep -i --line-number --column --color=always", fn_transform_cmd = function(query, cmd, opts) -- Uncomment to debug -- io.stdout:write(string.format("[DEBUG] %s\n", cmd .. query)) return cmd .. query end }) ```
1 parent 160e32d commit a33d382

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/fzf-lua/make_entry.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ M.preprocess = function(opts)
219219
end
220220
end
221221

222+
-- For custom command transformations (#1927)
223+
opts.fn_transform_cmd =
224+
load_config_section("__resume_data.opts.fn_transform_cmd", "function", true)
225+
if opts.fn_transform_cmd then
226+
local query = argv(nil, opts.debug)
227+
opts.cmd = opts.fn_transform_cmd(query, opts.cmd:gsub("{argv.*}", "") ,opts)
228+
end
229+
222230
-- nifty hack to avoid having to double escape quotations
223231
-- see my comment inside 'live_grep' initial_command code
224232
if opts.argv_expr then

0 commit comments

Comments
 (0)