Skip to content

Commit 8a09887

Browse files
committed
feat(marks): customize highlights (#2353)
```lua :FzfLua marks hls.buf_nr=DiffText hls.path_linenr=IncSearch hls.path_colnr=CurSearch ```
1 parent 7b730b6 commit 8a09887

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

lua/fzf-lua/defaults.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,12 +1179,13 @@ M.defaults.profiles = {
11791179
}
11801180

11811181
M.defaults.marks = {
1182-
fzf_opts = { ["--no-multi"] = true },
1183-
actions = {
1182+
fzf_opts = { ["--no-multi"] = true },
1183+
actions = {
11841184
["enter"] = actions.goto_mark,
11851185
["ctrl-x"] = { fn = actions.mark_del, reload = true }
11861186
},
1187-
previewer = { _ctor = previewers.builtin.marks },
1187+
previewer = { _ctor = previewers.builtin.marks },
1188+
_cached_hls = { "buf_nr", "path_linenr", "path_colnr" },
11881189
}
11891190

11901191
M.defaults.changes = {

lua/fzf-lua/previewer/builtin.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ end
14761476

14771477
function Previewer.marks:parse_entry(entry_str)
14781478
local bufnr = nil
1479-
local mark, lnum, col, filepath = entry_str:match("(.)%s+(%d+)%s+(%d+)%s+(.*)")
1479+
local mark, lnum, col, filepath = entry_str:match("([^ ])%s+(%d+)%s+(%d+)%s+(.*)")
14801480
if not mark then return {} end
14811481
-- try to acquire position from sending buffer
14821482
-- if this succeeds (line>0) the mark is inside
@@ -1489,7 +1489,7 @@ function Previewer.marks:parse_entry(entry_str)
14891489
return vim.api.nvim_buf_get_mark(buf, mark)
14901490
end)
14911491
if pos and pos[1] > 0 then
1492-
assert(pos[1] == tonumber(lnum))
1492+
assert(pos[1] == tonumber(lnum) or self.win.src_winid == self.win.fzf_winid)
14931493
bufnr = self.win.src_bufnr
14941494
filepath = api.nvim_buf_get_name(bufnr)
14951495
end

lua/fzf-lua/providers/nvim.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ M.marks = function(opts)
268268
text = path.HOME_to_tilde(text)
269269
end
270270
if not pattern or string.match(mark, pattern) then
271-
table.insert(entries, string.format(" %-15s %15s %15s %s",
272-
utils.ansi_codes.yellow(mark),
273-
utils.ansi_codes.blue(line),
274-
utils.ansi_codes.green(col),
271+
table.insert(entries, string.format("%s %s %s %s",
272+
utils.ansi_codes[opts.hls.buf_nr](string.format("%4s", mark)),
273+
utils.ansi_codes[opts.hls.path_linenr](string.format("%4s", tostring(line))),
274+
utils.ansi_codes[opts.hls.path_colnr](string.format("%3s", tostring(col))),
275275
text))
276276
end
277277
end

0 commit comments

Comments
 (0)