Skip to content

Commit

Permalink
feat: add support of light theme (yetone#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
tang-hi authored Aug 24, 2024
1 parent dd6bfad commit 8b55833
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
4 changes: 4 additions & 0 deletions lua/avante/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ M.defaults = {
hints = {
enabled = true,
},
--- @class AvanteThemeConfig
--- @field theme "light" | "dark"
--- @type string
theme = "dark",
}

---@type avante.Config
Expand Down
27 changes: 19 additions & 8 deletions lua/avante/highlights.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
local api = vim.api
local Config = require("avante.config")

local M = {
TITLE = "AvanteTitle",
REVERSED_TITLE = "AvanteReversedTitle",
SUBTITLE = "AvanteSubtitle",
REVERSED_SUBTITLE = "AvanteReversedSubtitle",
THRIDTITLE = "AvanteThirdTitle",
REVERSED_THRIDTITLE = "AvanteReversedThirdTitle",
THIRDTITLE = "AvanteThirdTitle",
REVERSED_THIRDTITLE = "AvanteReversedThirdTitle",
REVERSED_NORMAL = "AvanteReversedNormal",
}

Expand All @@ -18,12 +19,22 @@ M.setup = function()
local normal_float = api.nvim_get_hl(0, { name = "NormalFloat" })

api.nvim_set_hl(0, M.REVERSED_NORMAL, { fg = normal.bg })
api.nvim_set_hl(0, M.TITLE, { fg = "#1e222a", bg = "#98c379" })
api.nvim_set_hl(0, M.REVERSED_TITLE, { fg = "#98c379" })
api.nvim_set_hl(0, M.SUBTITLE, { fg = "#1e222a", bg = "#56b6c2" })
api.nvim_set_hl(0, M.REVERSED_SUBTITLE, { fg = "#56b6c2" })
api.nvim_set_hl(0, M.THRIDTITLE, { fg = "#ABB2BF", bg = "#353B45" })
api.nvim_set_hl(0, M.REVERSED_THRIDTITLE, { fg = "#353B45" })

if Config.defaults.theme == "light" then
api.nvim_set_hl(0, M.TITLE, { fg = "#1e222a", bg = "#98c379" })
api.nvim_set_hl(0, M.REVERSED_TITLE, { fg = "#98c379" })
api.nvim_set_hl(0, M.SUBTITLE, { fg = "#1e222a", bg = "#7998c3" })
api.nvim_set_hl(0, M.REVERSED_SUBTITLE, { fg = "#7998c3" })
api.nvim_set_hl(0, M.THIRDTITLE, { fg = "#1e222a", bg = "#a479c3" })
api.nvim_set_hl(0, M.REVERSED_THIRDTITLE, { fg = "#a479c3" })
else
api.nvim_set_hl(0, M.TITLE, { fg = "#1e222a", bg = "#98c379" })
api.nvim_set_hl(0, M.REVERSED_TITLE, { fg = "#98c379" })
api.nvim_set_hl(0, M.SUBTITLE, { fg = "#1e222a", bg = "#56b6c2" })
api.nvim_set_hl(0, M.REVERSED_SUBTITLE, { fg = "#56b6c2" })
api.nvim_set_hl(0, M.THIRDTITLE, { fg = "#ABB2BF", bg = "#353B45" })
api.nvim_set_hl(0, M.REVERSED_THIRDTITLE, { fg = "#353B45" })
end

api.nvim_set_hl(M.hint_ns, "NormalFloat", { fg = normal_float.fg, bg = normal_float.bg })

Expand Down
4 changes: 2 additions & 2 deletions lua/avante/sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,8 @@ function Sidebar:render_input_container()
self.input_container.winid,
self.input_container.bufnr,
header_text,
Highlights.THRIDTITLE,
Highlights.REVERSED_THRIDTITLE
Highlights.THIRDTITLE,
Highlights.REVERSED_THIRDTITLE
)
end

Expand Down

0 comments on commit 8b55833

Please sign in to comment.