Skip to content

Commit

Permalink
feat(diff): set highlights round robin (#290)
Browse files Browse the repository at this point in the history
* feat(diff): set highlights round robin

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* docs: add notes about conflict highlight group

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
  • Loading branch information
aarnphm authored Aug 27, 2024
1 parent ddf33a4 commit 10f27d2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions lua/avante/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 10f27d2

Please sign in to comment.