create highlight group for filename in finder grep
This commit is contained in:
@@ -4,6 +4,7 @@ function M.load_theme()
|
|||||||
highlights = function(c, tool)
|
highlights = function(c, tool)
|
||||||
c.bg_float = tool(152)
|
c.bg_float = tool(152)
|
||||||
return {
|
return {
|
||||||
|
FinderPath = { fg = c.muted },
|
||||||
Whitespace = { fg = c.outline_light },
|
Whitespace = { fg = c.outline_light },
|
||||||
ModeMsg = { fg = c.yellow, bg = c.none, bold = true },
|
ModeMsg = { fg = c.yellow, bg = c.none, bold = true },
|
||||||
WinSeparator = { fg = c.outline, bg = c.base },
|
WinSeparator = { fg = c.outline, bg = c.base },
|
||||||
|
|||||||
@@ -245,10 +245,29 @@ local function render()
|
|||||||
vim.api.nvim_buf_set_lines(S.buf_res, 0, -1, false, view)
|
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)
|
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, 'FinderMatch', { link = 'Search', default = true })
|
||||||
|
vim.api.nvim_set_hl(0, 'FinderPath', { fg = '#888888', default = true })
|
||||||
|
|
||||||
for i = 1, #view do
|
for i = 1, #view do
|
||||||
local idx = S.scroll + i
|
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]
|
local spans = S.positions[idx]
|
||||||
if spans then
|
if spans then
|
||||||
for _, se in ipairs(spans) do
|
for _, se in ipairs(spans) do
|
||||||
|
|||||||
Reference in New Issue
Block a user