From 10f27d2040f5f719b8bafedeb5f13de838b3ddb9 Mon Sep 17 00:00:00 2001 From: Aaron Pham Date: Tue, 27 Aug 2024 13:52:46 -0400 Subject: [PATCH] feat(diff): set highlights round robin (#290) * feat(diff): set highlights round robin Signed-off-by: Aaron Pham * docs: add notes about conflict highlight group Signed-off-by: Aaron Pham --------- Signed-off-by: Aaron Pham --- README.md | 23 +++++++++++++++-------- lua/avante/highlights.lua | 10 ++++++++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 783b563..af45124 100644 --- a/README.md +++ b/README.md @@ -203,14 +203,21 @@ The following key bindings are available for use with `avante.nvim`: ## Highlight Groups -| Highlight Group | Description | -|-----------------|-------------| -| AvanteTitle | Title | -| AvanteReversedTitle | Used for rounded border | -| AvanteSubtitle | Selected code title | -| AvanteReversedSubtitle | Used for rounded border | -| AvanteThirdTitle | Prompt title | -| AvanteReversedThirdTitle | Used for rounded border | + +| Highlight Group | Description | Notes | +|-----------------|-------------|-------| +| AvanteTitle | Title | | +| AvanteReversedTitle | Used for rounded border | | +| AvanteSubtitle | Selected code title | | +| AvanteReversedSubtitle | Used for rounded border | | +| AvanteThirdTitle | Prompt title | | +| AvanteReversedThirdTitle | Used for rounded border | | +| AvanteConflictCurrent | Current conflict highlight | Default to `Config.highlights.diff.current` | +| AvanteConflictIncoming | Incoming conflict highlight | Default to `Config.highlights.diff.incoming` | +| AvanteConflictCurrentLabel | Current conflict label highlight | Default to shade of `AvanteConflictCurrent` | +| AvanteConflictIncomingLabel | Incoming conflict label highlight | Default to shade of `AvanteConflictIncoming` | + +See [highlights.lua](./lua/avante/highlights.lua) for more information ## TODOs diff --git a/lua/avante/highlights.lua b/lua/avante/highlights.lua index 9389b3c..71e0b93 100644 --- a/lua/avante/highlights.lua +++ b/lua/avante/highlights.lua @@ -65,8 +65,14 @@ M.conflict_highlights = function(opts) opts = opts or Config.diff.highlights local get_default_colors = function(key, hl) - local getter = api.nvim_get_hl(0, { name = opts[key:lower()] }) - return getter.bg or hl.bg + --- We will first check for the hl name. If plugins set this then we won't use the default opts[var_accesor] + local cl + cl = api.nvim_get_hl(0, { name = hl.name }) + if cl ~= nil then + return cl.bg or hl.bg + end + cl = api.nvim_get_hl(0, { name = opts[key:lower()] }) + return cl.bg or hl.bg end local get_shade = function(hl)