create highlight group for filename in finder grep

This commit is contained in:
2026-01-27 01:02:50 +02:00
parent d7122e9345
commit 70486dda84
2 changed files with 21 additions and 1 deletions

View File

@@ -245,10 +245,29 @@ local function render()
vim.api.nvim_buf_set_lines(S.buf_res, 0, -1, false, view)
vim.api.nvim_buf_clear_namespace(S.buf_res, S.ns, 0, -1)
-- match highlights
-- highlight groups
vim.api.nvim_set_hl(0, 'FinderMatch', { link = 'Search', default = true })
vim.api.nvim_set_hl(0, 'FinderPath', { fg = '#888888', default = true })
for i = 1, #view do
local idx = S.scroll + i
local line = view[i]
-- In grep mode, highlight the "file:line:col:" prefix in gray
if S.mode == 'grep' and line then
local prefix_end = line:find('^.-:%d+:%d+:')
if prefix_end then
local _, epos = line:find('^.-:%d+:%d+:')
if epos then
pcall(vim.api.nvim_buf_set_extmark, S.buf_res, S.ns, i - 1, 0, {
end_col = epos,
hl_group = 'FinderPath',
})
end
end
end
-- match highlights (query matches in orange)
local spans = S.positions[idx]
if spans then
for _, se in ipairs(spans) do