Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
parent
c33ab80d88
commit
96d060db83
@ -135,7 +135,7 @@ M.defaults = {
|
||||
},
|
||||
},
|
||||
windows = {
|
||||
---@type "right" | "left" | "top" | "bottom"
|
||||
---@alias AvantePosition "right" | "left" | "top" | "bottom"
|
||||
position = "right",
|
||||
wrap = true, -- similar to vim.o.wrap
|
||||
width = 30, -- default % based on available width in vertical layout
|
||||
@ -171,12 +171,10 @@ M.options = {}
|
||||
---@field highlights AvanteConflictHighlights
|
||||
M.diff = {}
|
||||
|
||||
---@class AvanteHintsConfig
|
||||
---@field enabled boolean
|
||||
M.hints = {}
|
||||
|
||||
---@param opts? avante.Config
|
||||
function M.setup(opts)
|
||||
vim.validate({ opts = { opts, "table", true } })
|
||||
|
||||
M.options = vim.tbl_deep_extend(
|
||||
"force",
|
||||
M.defaults,
|
||||
@ -184,7 +182,7 @@ function M.setup(opts)
|
||||
---@type avante.Config
|
||||
{
|
||||
behaviour = {
|
||||
support_paste_from_clipboard = M.support_paste_image(),
|
||||
support_paste_from_clipboard = M.support_paste_image(true),
|
||||
},
|
||||
}
|
||||
)
|
||||
@ -193,25 +191,28 @@ function M.setup(opts)
|
||||
M.options.silent_warning = not M.options.debug
|
||||
end
|
||||
|
||||
vim.validate({ provider = { M.options.provider, "string", false } })
|
||||
|
||||
M.diff = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
M.options.diff,
|
||||
{ mappings = M.options.mappings.diff, highlights = M.options.highlights.diff }
|
||||
)
|
||||
M.hints = vim.tbl_deep_extend("force", {}, M.options.hints)
|
||||
|
||||
if next(M.options.vendors) ~= nil then
|
||||
for k, v in pairs(M.options.vendors) do
|
||||
M.options.vendors[k] = type(v) == "function" and v() or v
|
||||
end
|
||||
vim.validate({ vendors = { M.options.vendors, "table", true } })
|
||||
end
|
||||
end
|
||||
|
||||
---@param opts? avante.Config
|
||||
function M.override(opts)
|
||||
opts = opts or {}
|
||||
M.options = vim.tbl_deep_extend("force", M.options, opts)
|
||||
vim.validate({ opts = { opts, "table", true } })
|
||||
|
||||
M.options = vim.tbl_deep_extend("force", M.options, opts or {})
|
||||
if not M.options.silent_warning then
|
||||
-- set silent_warning to true if debug is false
|
||||
M.options.silent_warning = not M.options.debug
|
||||
@ -223,12 +224,12 @@ function M.override(opts)
|
||||
M.options.diff,
|
||||
{ mappings = M.options.mappings.diff, highlights = M.options.highlights.diff }
|
||||
)
|
||||
M.hints = vim.tbl_deep_extend("force", {}, M.options.hints)
|
||||
|
||||
if next(M.options.vendors) ~= nil then
|
||||
for k, v in pairs(M.options.vendors) do
|
||||
M.options.vendors[k] = type(v) == "function" and v() or v
|
||||
end
|
||||
vim.validate({ vendors = { M.options.vendors, "table", true } })
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,11 +14,11 @@ local Highlights = {
|
||||
}
|
||||
|
||||
Highlights.conflict = {
|
||||
CURRENT = { name = "AvanteConflictCurrent", bg = 4218238 }, -- #405d7e
|
||||
CURRENT = { name = "AvanteConflictCurrent", bg = 4218238, bold = true }, -- #405d7e
|
||||
CURRENT_LABEL = { name = "AvanteConflictCurrentLabel", link = "CURRENT", shade = 60 },
|
||||
INCOMING = { name = "AvanteConflictIncoming", bg = 3229523 }, -- #314753
|
||||
INCOMING = { name = "AvanteConflictIncoming", bg = 3229523, bold = true }, -- #314753
|
||||
INCOMING_LABEL = { name = "AvanteConflictIncomingLabel", link = "INCOMING", shade = 60 },
|
||||
ANCESTOR = { name = "AvanteConflictAncestor", bg = 6824314 }, -- #68217A
|
||||
ANCESTOR = { name = "AvanteConflictAncestor", bg = 6824314, bold = true }, -- #68217A
|
||||
ANCESTOR_LABEL = { name = "AvanteConflictAncestorLabel", link = "ANCESTOR", shade = 60 },
|
||||
}
|
||||
|
||||
@ -64,15 +64,14 @@ end
|
||||
M.conflict_highlights = function(opts)
|
||||
opts = opts or Config.diff.highlights
|
||||
|
||||
local get_highlights = function(key, hl)
|
||||
local cl = api.nvim_get_hl(0, { name = opts[key:lower()] })
|
||||
return cl ~= nil and cl or api.nvim_get_hl(0, { name = hl.name })
|
||||
end
|
||||
|
||||
local get_default_colors = function(key, hl)
|
||||
--- We will first check for user custom highlight. Then fallback to default name highlight.
|
||||
local cl
|
||||
cl = api.nvim_get_hl(0, { name = opts[key:lower()] })
|
||||
if cl ~= nil then
|
||||
return cl.bg or hl.bg
|
||||
end
|
||||
cl = api.nvim_get_hl(0, { name = hl.name })
|
||||
return cl.bg or hl.bg
|
||||
return get_highlights(key, hl).bg or hl.bg
|
||||
end
|
||||
|
||||
local get_shade = function(hl)
|
||||
@ -85,7 +84,11 @@ M.conflict_highlights = function(opts)
|
||||
if hl.link ~= nil then
|
||||
api.nvim_set_hl(0, hl.name, { bg = get_shade(hl), default = true })
|
||||
else
|
||||
api.nvim_set_hl(0, hl.name, { bg = get_default_colors(key, hl), default = true, bold = true })
|
||||
api.nvim_set_hl(
|
||||
0,
|
||||
hl.name,
|
||||
{ bg = get_default_colors(key, hl), default = true, bold = get_highlights(key, hl).bold or hl.bold }
|
||||
)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Loading…
x
Reference in New Issue
Block a user