Skip to content

fix(nvim): use configurable grep_match hl in preview (#646) - #647

Merged
dmtrKovalenko merged 1 commit into
mainfrom
triage-bot/issue-646
Jul 2, 2026
Merged

dmtrKovalenko merged 1 commit into
mainfrom
triage-bot/issue-646

Conversation

@gustav-fff

Copy link
Copy Markdown
Collaborator

Closes #646

Root cause

lua/fff/location_utils.lua hardcoded IncSearch for grep match highlights in the preview window (lines 184, 228), while the results list uses config.hl.grep_match (lua/fff/picker_ui/grep_renderer.lua:232). Overriding hl.grep_match in the user config styled the results list but not the preview, and overriding the global IncSearch group did not propagate either (likely due to the preview's winhighlight remapping Normal and treesitter groups painting over the extmark background in some colorschemes).

Fix

Read config.hl.grep_match in highlight_grep_matches and use it for both the fuzzy and plain/regex code paths, falling back to IncSearch when unset. Preview and results now share the same configurable highlight group.

Steps to reproduce

Setup:

-- repro.lua
vim.pack.add({ "https://github.com/dmtrKovalenko/fff.nvim" })
vim.api.nvim_create_autocmd("PackChanged", {
  callback = function(ev)
    local name, kind = ev.data.spec.name, ev.data.kind
    if name == "fff.nvim" and (kind == "install" or kind == "update") then
      if not ev.data.active then vim.cmd.packadd("fff.nvim") end
      require("fff.download").download_or_build_binary()
    end
  end,
})
vim.g.fff = { lazy_sync = true }
-- Try to restyle grep matches:
vim.api.nvim_set_hl(0, "IncSearch", { bg = "#ff00ff", fg = "#000000" })

Trigger:

nvim -u repro.lua
:lua require("fff").live_grep()

Type any query.

Expected: matched substrings in the preview have the magenta background.
Actual (pre-fix): matches in the results list are magenta, matches in the preview window keep the theme's washed-out IncSearch (or no background at all under gruvbox-material, per screenshots in the issue).

How verified

Manual repro on macOS with the config above; after the fix the preview highlights honor the overridden IncSearch, and setting hl.grep_match = 'Visual' in the fff config now restyles both list and preview consistently.

Automated triage via Gustav. Honk-Honk 🪿

The preview window hardcoded 'IncSearch' for grep match highlights while
the results list uses config.hl.grep_match. Overriding grep_match had no
effect on the preview, forcing users to override the global IncSearch
group instead.

Refs #646
@dmtrKovalenko
dmtrKovalenko merged commit 4d13537 into main Jul 2, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Grep result highlight group IncSearch is not accessible in preview window

2 participants