From 313e252ecfd3252d2e39d7c012b0674388d65f8d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 9 Jun 2023 20:12:26 +0200 Subject: [PATCH] feat: highlight groups config --- lua/flash/config.lua | 6 ++++++ lua/flash/highlight.lua | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/flash/config.lua b/lua/flash/config.lua index 85f5a2f..9427df2 100644 --- a/lua/flash/config.lua +++ b/lua/flash/config.lua @@ -47,6 +47,12 @@ local defaults = { matches = true, -- extmark priority priority = 5000, + groups = { + match = "FlashMatch", + current = "FlashCurrent", + backdrop = "FlashBackdrop", + label = "FlashLabel", + }, }, -- You can override the default options for a specific mode. -- Use it with `require("flash").jump({mode = "forward"})` diff --git a/lua/flash/highlight.lua b/lua/flash/highlight.lua index b926c7d..226edb4 100644 --- a/lua/flash/highlight.lua +++ b/lua/flash/highlight.lua @@ -33,7 +33,7 @@ function M.backdrop(state) -- extmarks priority rendering works for line = from[1], to[1] do vim.api.nvim_buf_set_extmark(buf, M.ns, line - 1, line == from[1] and from[2] or 0, { - hl_group = "FlashBackdrop", + hl_group = state.config.highlight.groups.backdrop, end_row = line == to[1] and line - 1 or line, hl_eol = line ~= to[1], end_col = line == to[1] and to[2] or from[2], @@ -52,14 +52,14 @@ function M.update(state) M.backdrop(state) end - for _, match in ipairs(state.results) do + for m, match in ipairs(state.results) do local buf = vim.api.nvim_win_get_buf(match.win) if state.config.highlight.matches then vim.api.nvim_buf_set_extmark(buf, M.ns, match.from[1] - 1, match.from[2], { end_row = match.to[1] - 1, end_col = match.to[2] + 1, - hl_group = match.current and match.win == state.win and "FlashCurrent" or "FlashMatch", + hl_group = state.current == m and state.config.highlight.groups.current or state.config.highlight.groups.match, strict = false, priority = state.config.highlight.priority + 1, }) @@ -67,7 +67,7 @@ function M.update(state) if match.label then vim.api.nvim_buf_set_extmark(buf, M.ns, match.to[1] - 1, match.to[2] + 1, { - virt_text = { { match.label, "FlashLabel" } }, + virt_text = { { match.label, state.config.highlight.groups.label } }, virt_text_pos = "overlay", strict = false, priority = state.config.highlight.priority + 2,