Skip to content

Commit 26b7c43

Browse files
committed
feat(grep): opts.regex convenience alias
Same as using `search=... no_esc=true`.
1 parent 6b0afd7 commit 26b7c43

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lua/fzf-lua/defaults.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,8 @@ M.defaults.git = {
849849
---@field raw_cmd? string
850850
---Initial search string.
851851
---@field search? string
852+
---Initial search pattern.
853+
---@field regex? string
852854
---Disable escaping of special characters in the search query, set to `2` to disable escaping and regex mode.
853855
---@field no_esc? integer|boolean
854856
---Enable live grep mode (search-as-you-type).

lua/fzf-lua/providers/grep.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ M.grep = function(opts)
2121
-- we need this for `actions.grep_lgrep`
2222
opts.__ACT_TO = opts.__ACT_TO or M.live_grep
2323

24+
-- regex as alias to search+no_esc
25+
if opts.regex then
26+
opts.search = opts.regex
27+
opts.no_esc = true
28+
opts.regex = nil
29+
end
30+
2431
if not opts.search and not opts.raw_cmd then
2532
-- resume implies no input prompt
2633
if opts.resume then
@@ -64,6 +71,13 @@ local function normalize_live_grep_opts(opts)
6471
opts = config.normalize_opts(opts, "grep")
6572
if not opts then return end
6673

74+
-- regex as alias to search+no_esc
75+
if opts.regex then
76+
opts.search = opts.regex
77+
opts.no_esc = true
78+
opts.regex = nil
79+
end
80+
6781
-- auto disable treesitter as it collides with cmd regex highlighting
6882
-- ignore if forced with `_treesitter = true` (#2511)
6983
if opts._treesitter == 1 then opts = utils.map_set(opts, "winopts.treesitter", false) end

0 commit comments

Comments
 (0)