feat(diff): set highlights round robin (#290)

* 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>
This commit is contained in:
Aaron Pham 2024-08-27 13:52:46 -04:00 committed by GitHub
parent ddf33a4774
commit 10f27d2040
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 10 deletions

View File

@ -203,14 +203,21 @@ The following key bindings are available for use with `avante.nvim`:
## Highlight Groups ## Highlight Groups
| Highlight Group | Description |
|-----------------|-------------| | Highlight Group | Description | Notes |
| AvanteTitle | Title | |-----------------|-------------|-------|
| AvanteReversedTitle | Used for rounded border | | AvanteTitle | Title | |
| AvanteSubtitle | Selected code title | | AvanteReversedTitle | Used for rounded border | |
| AvanteReversedSubtitle | Used for rounded border | | AvanteSubtitle | Selected code title | |
| AvanteThirdTitle | Prompt title | | AvanteReversedSubtitle | Used for rounded border | |
| AvanteReversedThirdTitle | 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 ## TODOs

View File

@ -65,8 +65,14 @@ M.conflict_highlights = function(opts)
opts = opts or Config.diff.highlights opts = opts or Config.diff.highlights
local get_default_colors = function(key, hl) local get_default_colors = function(key, hl)
local getter = api.nvim_get_hl(0, { name = opts[key:lower()] }) --- We will first check for the hl name. If plugins set this then we won't use the default opts[var_accesor]
return getter.bg or hl.bg 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 end
local get_shade = function(hl) local get_shade = function(hl)