feat: set cs properties

dev-doc
Pocco81 3 years ago
parent dc217296eb
commit d51be55ada

@ -1,4 +1,5 @@
local util = require("catppuccino.utils.util") local util = require("catppuccino.utils.util")
local colors_util = require("catppuccino.utils.colors")
local M = {} local M = {}
@ -13,7 +14,6 @@ local function set_cs(val)
end end
local function get_base() local function get_base()
local cpt = get_cs() local cpt = get_cs()
return { return {
@ -134,11 +134,9 @@ local function get_base()
-- debugging -- debugging
debugPC = {bg = cpt.bg_sidebar}, -- used for highlighting the current line in terminal-debug debugPC = {bg = cpt.bg_sidebar}, -- used for highlighting the current line in terminal-debug
debugBreakpoint = {bg = util.darken(cpt.info, 0.1), fg = cpt.info}, -- used for breakpoint colors in terminal-debug debugBreakpoint = {bg = util.darken(cpt.info, 0.1), fg = cpt.info}, -- used for breakpoint colors in terminal-debug
-- illuminate -- illuminate
illuminatedWord = {bg = cpt.fg_gutter}, illuminatedWord = {bg = cpt.fg_gutter},
illuminatedCurWord = {bg = cpt.fg_gutter}, illuminatedCurWord = {bg = cpt.fg_gutter},
-- diff -- diff
diffAdded = {fg = cpt.git.add}, diffAdded = {fg = cpt.git.add},
diffRemoved = {fg = cpt.git.delete}, diffRemoved = {fg = cpt.git.delete},
@ -148,18 +146,15 @@ local function get_base()
diffFile = {fg = cpt.blue}, diffFile = {fg = cpt.blue},
diffLine = {fg = cpt.comment}, diffLine = {fg = cpt.comment},
diffIndexLine = {fg = cpt.magenta}, diffIndexLine = {fg = cpt.magenta},
-- git diff -- git diff
DiffAdd = {fg = cpt.diff.add, bg = cpt.bg}, -- diff mode: Added line |diff.txt| DiffAdd = {fg = cpt.diff.add, bg = cpt.bg}, -- diff mode: Added line |diff.txt|
DiffChange = {fg = cpt.diff.change, bg = cpt.bg}, -- diff mode: Changed line |diff.txt| DiffChange = {fg = cpt.diff.change, bg = cpt.bg}, -- diff mode: Changed line |diff.txt|
DiffDelete = {fg = cpt.diff.delete, bg = cpt.bg}, -- diff mode: Deleted line |diff.txt| DiffDelete = {fg = cpt.diff.delete, bg = cpt.bg}, -- diff mode: Deleted line |diff.txt|
DiffText = {fg = cpt.diff.text, bg = cpt.bg}, -- diff mode: Changed text within a changed line |diff.txt| DiffText = {fg = cpt.diff.text, bg = cpt.bg}, -- diff mode: Changed text within a changed line |diff.txt|
-- NeoVim -- NeoVim
healthError = {fg = cpt.error}, healthError = {fg = cpt.error},
healthSuccess = {fg = cpt.green_br}, healthSuccess = {fg = cpt.green_br},
healthWarning = {fg = cpt.warning}, healthWarning = {fg = cpt.warning},
-- misc -- misc
-- glyphs -- glyphs
@ -169,7 +164,7 @@ local function get_base()
GlyphPalette4 = {fg = cpt.blue}, GlyphPalette4 = {fg = cpt.blue},
GlyphPalette6 = {fg = cpt.green_br}, GlyphPalette6 = {fg = cpt.green_br},
GlyphPalette7 = {fg = cpt.fg}, GlyphPalette7 = {fg = cpt.fg},
GlyphPalette9 = {fg = cpt.red}, GlyphPalette9 = {fg = cpt.red}
} }
end end
@ -198,6 +193,19 @@ local function get_integrations()
return final_integrations return final_integrations
end end
local function get_properties()
local cpt = get_cs()
local props = {
termguicolors = true,
background = "light"
}
if (colors_util.assert_brightness(cpt.bg)) then
props["background"] = "dark"
end
return props
end
function M.apply(cs) function M.apply(cs)
_G.cpc = require("catppuccino.config").options _G.cpc = require("catppuccino.config").options
@ -212,7 +220,8 @@ function M.apply(cs)
local theme = {} local theme = {}
theme.base = get_base() theme.base = get_base()
theme.plugins = get_integrations() theme.integrations = get_integrations()
theme.properties = get_properties()
-- uninstantiate to avoid poluting global scope and because they are not needed anymore -- uninstantiate to avoid poluting global scope and because they are not needed anymore
_G.cpc = nil _G.cpc = nil

@ -114,6 +114,12 @@ function util.syntax(tbl)
end end
end end
function util.properties(tbl)
for property, value in pairs(tbl) do
vim.o[property] = value
end
end
function util.terminal(theme) function util.terminal(theme)
g.terminal_color_0 = theme.colors.black g.terminal_color_0 = theme.colors.black
g.terminal_color_1 = theme.colors.red g.terminal_color_1 = theme.colors.red
@ -140,12 +146,11 @@ function util.load(theme)
vim.cmd("syntax reset") vim.cmd("syntax reset")
end end
o.background = "dark"
o.termguicolors = true
g.colors_name = "catppuccino" g.colors_name = "catppuccino"
util.properties(theme.properties)
util.syntax(theme.base) util.syntax(theme.base)
util.syntax(theme.plugins) util.syntax(theme.integrations)
-- if opts.ui.terminal then -- if opts.ui.terminal then
-- util.terminal(theme) -- util.terminal(theme)

Loading…
Cancel
Save