Skip to content

Commit 5eb0783

Browse files
committed
feat(live_grep): enable treesitter (closes #2511)
Disabled by default, enable with `_treesitter=true`: ```lua :FzfLua live_grep _treesitter=true -- or :lua FzfLua.live_grep({ _treesitter = true }) ``` or permanently via setup under grep: ```lua require("fzf-lua").setup({ grep = { _treesitter = true, -- recommended to use with "--colors match:style:underline" rg_opts = "--column --line-number --no-heading --color=always --smart-case " .. "--max-columns=4096 --colors match:style:underline -e" } }) ```
1 parent 506a508 commit 5eb0783

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lua/fzf-lua/defaults.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ M.defaults.grep = {
786786
-- live_grep_glob options
787787
glob_flag = "--iglob", -- for case sensitive globs use '--glob'
788788
glob_separator = "%s%-%-", -- query separator pattern (lua): ' --'
789-
_treesitter = true,
789+
_treesitter = 1, -- auto disable in live grep
790790
_headers = { "actions", "cwd" },
791791
}
792792

lua/fzf-lua/providers/grep.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ M.grep = function(opts)
6060
end
6161

6262
local function normalize_live_grep_opts(opts)
63-
-- disable treesitter as it collides with cmd regex highlighting
64-
opts = opts or {}
65-
opts._treesitter = false
66-
utils.map_set(opts, "winopts.treesitter", nil)
67-
6863
---@type fzf-lua.config.Grep
6964
opts = config.normalize_opts(opts, "grep")
7065
if not opts then return end
7166

67+
-- auto disable treesitter as it collides with cmd regex highlighting
68+
-- ignore if forced with `_treesitter = true` (#2511)
69+
local _ts = utils.map_get(opts, "_treesitter")
70+
if _ts == 1 then opts = utils.map_set(opts, "winopts.treesitter", false) end
71+
7272
-- we need this for `actions.grep_lgrep`
7373
opts.__ACT_TO = opts.__ACT_TO or M.grep
7474

0 commit comments

Comments
 (0)