From 70486dda84d1841379272e44a0560d3ee9b3291c Mon Sep 17 00:00:00 2001 From: Tomas Mirchev Date: Tue, 27 Jan 2026 01:02:50 +0200 Subject: [PATCH] create highlight group for filename in finder grep --- lua/modules/theme.lua | 1 + lua/plugins/finder.lua | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lua/modules/theme.lua b/lua/modules/theme.lua index ff1d501..3778ef1 100644 --- a/lua/modules/theme.lua +++ b/lua/modules/theme.lua @@ -4,6 +4,7 @@ function M.load_theme() highlights = function(c, tool) c.bg_float = tool(152) return { + FinderPath = { fg = c.muted }, Whitespace = { fg = c.outline_light }, ModeMsg = { fg = c.yellow, bg = c.none, bold = true }, WinSeparator = { fg = c.outline, bg = c.base }, diff --git a/lua/plugins/finder.lua b/lua/plugins/finder.lua index c10c1be..29ea847 100644 --- a/lua/plugins/finder.lua +++ b/lua/plugins/finder.lua @@ -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