catppuccin.go

  1package theme
  2
  3import (
  4	catppuccin "github.com/catppuccin/go"
  5	"github.com/charmbracelet/lipgloss/v2"
  6)
  7
  8// CatppuccinTheme implements the Theme interface with Catppuccin colors.
  9// It provides both dark (Mocha) and light (Latte) variants.
 10type CatppuccinTheme struct {
 11	BaseTheme
 12}
 13
 14// NewCatppuccinMochaTheme creates a new instance of the Catppuccin Mocha theme.
 15func NewCatppuccinMochaTheme() *CatppuccinTheme {
 16	// Get the Catppuccin palette
 17	mocha := catppuccin.Mocha
 18
 19	theme := &CatppuccinTheme{}
 20
 21	// Base colors
 22	theme.PrimaryColor = lipgloss.Color(mocha.Blue().Hex)
 23	theme.SecondaryColor = lipgloss.Color(mocha.Mauve().Hex)
 24	theme.AccentColor = lipgloss.Color(mocha.Peach().Hex)
 25
 26	// Status colors
 27	theme.ErrorColor = lipgloss.Color(mocha.Red().Hex)
 28	theme.WarningColor = lipgloss.Color(mocha.Peach().Hex)
 29	theme.SuccessColor = lipgloss.Color(mocha.Green().Hex)
 30	theme.InfoColor = lipgloss.Color(mocha.Blue().Hex)
 31
 32	// Text colors
 33	theme.TextColor = lipgloss.Color(mocha.Text().Hex)
 34	theme.TextMutedColor = lipgloss.Color(mocha.Subtext0().Hex)
 35	theme.TextEmphasizedColor = lipgloss.Color(mocha.Lavender().Hex)
 36
 37	// Background colors
 38	theme.BackgroundColor = lipgloss.Color("#212121")          // From existing styles
 39	theme.BackgroundSecondaryColor = lipgloss.Color("#2c2c2c") // From existing styles
 40	theme.BackgroundDarkerColor = lipgloss.Color("#181818")    // From existing styles
 41
 42	// Border colors
 43	theme.BorderNormalColor = lipgloss.Color("#4b4c5c") // From existing styles
 44	theme.BorderFocusedColor = lipgloss.Color(mocha.Blue().Hex)
 45	theme.BorderDimColor = lipgloss.Color(mocha.Surface0().Hex)
 46
 47	// Diff view colors
 48	theme.DiffAddedColor = lipgloss.Color("#478247")               // From existing diff.go
 49	theme.DiffRemovedColor = lipgloss.Color("#7C4444")             // From existing diff.go
 50	theme.DiffContextColor = lipgloss.Color("#a0a0a0")             // From existing diff.go
 51	theme.DiffHunkHeaderColor = lipgloss.Color("#a0a0a0")          // From existing diff.go
 52	theme.DiffHighlightAddedColor = lipgloss.Color("#DAFADA")      // From existing diff.go
 53	theme.DiffHighlightRemovedColor = lipgloss.Color("#FADADD")    // From existing diff.go
 54	theme.DiffAddedBgColor = lipgloss.Color("#303A30")             // From existing diff.go
 55	theme.DiffRemovedBgColor = lipgloss.Color("#3A3030")           // From existing diff.go
 56	theme.DiffContextBgColor = lipgloss.Color("#212121")           // From existing diff.go
 57	theme.DiffLineNumberColor = lipgloss.Color("#888888")          // From existing diff.go
 58	theme.DiffAddedLineNumberBgColor = lipgloss.Color("#293229")   // From existing diff.go
 59	theme.DiffRemovedLineNumberBgColor = lipgloss.Color("#332929") // From existing diff.go
 60
 61	// Markdown colors
 62	theme.MarkdownTextColor = lipgloss.Color(mocha.Text().Hex)
 63	theme.MarkdownHeadingColor = lipgloss.Color(mocha.Mauve().Hex)
 64	theme.MarkdownLinkColor = lipgloss.Color(mocha.Sky().Hex)
 65	theme.MarkdownLinkTextColor = lipgloss.Color(mocha.Pink().Hex)
 66	theme.MarkdownCodeColor = lipgloss.Color(mocha.Green().Hex)
 67	theme.MarkdownBlockQuoteColor = lipgloss.Color(mocha.Yellow().Hex)
 68	theme.MarkdownEmphColor = lipgloss.Color(mocha.Yellow().Hex)
 69	theme.MarkdownStrongColor = lipgloss.Color(mocha.Peach().Hex)
 70	theme.MarkdownHorizontalRuleColor = lipgloss.Color(mocha.Overlay0().Hex)
 71	theme.MarkdownListItemColor = lipgloss.Color(mocha.Blue().Hex)
 72	theme.MarkdownListEnumerationColor = lipgloss.Color(mocha.Sky().Hex)
 73	theme.MarkdownImageColor = lipgloss.Color(mocha.Sapphire().Hex)
 74	theme.MarkdownImageTextColor = lipgloss.Color(mocha.Pink().Hex)
 75	theme.MarkdownCodeBlockColor = lipgloss.Color(mocha.Text().Hex)
 76
 77	// Syntax highlighting colors
 78	theme.SyntaxCommentColor = lipgloss.Color(mocha.Overlay1().Hex)
 79	theme.SyntaxKeywordColor = lipgloss.Color(mocha.Pink().Hex)
 80	theme.SyntaxFunctionColor = lipgloss.Color(mocha.Green().Hex)
 81	theme.SyntaxVariableColor = lipgloss.Color(mocha.Sky().Hex)
 82	theme.SyntaxStringColor = lipgloss.Color(mocha.Yellow().Hex)
 83	theme.SyntaxNumberColor = lipgloss.Color(mocha.Teal().Hex)
 84	theme.SyntaxTypeColor = lipgloss.Color(mocha.Sky().Hex)
 85	theme.SyntaxOperatorColor = lipgloss.Color(mocha.Pink().Hex)
 86	theme.SyntaxPunctuationColor = lipgloss.Color(mocha.Text().Hex)
 87
 88	return theme
 89}
 90
 91// NewCatppuccinLatteTheme creates a new instance of the Catppuccin Latte theme.
 92func NewCatppuccinLatteTheme() *CatppuccinTheme {
 93	// Get the Catppuccin palette
 94	latte := catppuccin.Latte
 95
 96	theme := &CatppuccinTheme{}
 97
 98	// Base colors
 99	theme.PrimaryColor = lipgloss.Color(latte.Blue().Hex)
100	theme.SecondaryColor = lipgloss.Color(latte.Mauve().Hex)
101	theme.AccentColor = lipgloss.Color(latte.Peach().Hex)
102
103	// Status colors
104	theme.ErrorColor = lipgloss.Color(latte.Red().Hex)
105	theme.WarningColor = lipgloss.Color(latte.Peach().Hex)
106	theme.SuccessColor = lipgloss.Color(latte.Green().Hex)
107	theme.InfoColor = lipgloss.Color(latte.Blue().Hex)
108
109	// Text colors
110	theme.TextColor = lipgloss.Color(latte.Text().Hex)
111	theme.TextMutedColor = lipgloss.Color(latte.Subtext0().Hex)
112	theme.TextEmphasizedColor = lipgloss.Color(latte.Lavender().Hex)
113
114	// Background colors
115	theme.BackgroundColor = lipgloss.Color("#EEEEEE")          // Light equivalent
116	theme.BackgroundSecondaryColor = lipgloss.Color("#E0E0E0") // Light equivalent
117	theme.BackgroundDarkerColor = lipgloss.Color("#F5F5F5")    // Light equivalent
118
119	// Border colors
120	theme.BorderNormalColor = lipgloss.Color("#BDBDBD") // Light equivalent
121	theme.BorderFocusedColor = lipgloss.Color(latte.Blue().Hex)
122	theme.BorderDimColor = lipgloss.Color(latte.Surface0().Hex)
123
124	// Diff view colors
125	theme.DiffAddedColor = lipgloss.Color("#2E7D32")               // Light equivalent
126	theme.DiffRemovedColor = lipgloss.Color("#C62828")             // Light equivalent
127	theme.DiffContextColor = lipgloss.Color("#757575")             // Light equivalent
128	theme.DiffHunkHeaderColor = lipgloss.Color("#757575")          // Light equivalent
129	theme.DiffHighlightAddedColor = lipgloss.Color("#A5D6A7")      // Light equivalent
130	theme.DiffHighlightRemovedColor = lipgloss.Color("#EF9A9A")    // Light equivalent
131	theme.DiffAddedBgColor = lipgloss.Color("#E8F5E9")             // Light equivalent
132	theme.DiffRemovedBgColor = lipgloss.Color("#FFEBEE")           // Light equivalent
133	theme.DiffContextBgColor = lipgloss.Color("#F5F5F5")           // Light equivalent
134	theme.DiffLineNumberColor = lipgloss.Color("#9E9E9E")          // Light equivalent
135	theme.DiffAddedLineNumberBgColor = lipgloss.Color("#C8E6C9")   // Light equivalent
136	theme.DiffRemovedLineNumberBgColor = lipgloss.Color("#FFCDD2") // Light equivalent
137
138	// Markdown colors
139	theme.MarkdownTextColor = lipgloss.Color(latte.Text().Hex)
140	theme.MarkdownHeadingColor = lipgloss.Color(latte.Mauve().Hex)
141	theme.MarkdownLinkColor = lipgloss.Color(latte.Sky().Hex)
142	theme.MarkdownLinkTextColor = lipgloss.Color(latte.Pink().Hex)
143	theme.MarkdownCodeColor = lipgloss.Color(latte.Green().Hex)
144	theme.MarkdownBlockQuoteColor = lipgloss.Color(latte.Yellow().Hex)
145	theme.MarkdownEmphColor = lipgloss.Color(latte.Yellow().Hex)
146	theme.MarkdownStrongColor = lipgloss.Color(latte.Peach().Hex)
147	theme.MarkdownHorizontalRuleColor = lipgloss.Color(latte.Overlay0().Hex)
148	theme.MarkdownListItemColor = lipgloss.Color(latte.Blue().Hex)
149	theme.MarkdownListEnumerationColor = lipgloss.Color(latte.Sky().Hex)
150	theme.MarkdownImageColor = lipgloss.Color(latte.Sapphire().Hex)
151	theme.MarkdownImageTextColor = lipgloss.Color(latte.Pink().Hex)
152	theme.MarkdownCodeBlockColor = lipgloss.Color(latte.Text().Hex)
153
154	// Syntax highlighting colors
155	theme.SyntaxCommentColor = lipgloss.Color(latte.Overlay1().Hex)
156	theme.SyntaxKeywordColor = lipgloss.Color(latte.Pink().Hex)
157	theme.SyntaxFunctionColor = lipgloss.Color(latte.Green().Hex)
158	theme.SyntaxVariableColor = lipgloss.Color(latte.Sky().Hex)
159	theme.SyntaxStringColor = lipgloss.Color(latte.Yellow().Hex)
160	theme.SyntaxNumberColor = lipgloss.Color(latte.Teal().Hex)
161	theme.SyntaxTypeColor = lipgloss.Color(latte.Sky().Hex)
162	theme.SyntaxOperatorColor = lipgloss.Color(latte.Pink().Hex)
163	theme.SyntaxPunctuationColor = lipgloss.Color(latte.Text().Hex)
164
165	return theme
166}
167
168func init() {
169	// Register the Catppuccin themes with the theme manager
170	RegisterTheme("catppuccin-mocha", NewCatppuccinMochaTheme())
171	RegisterTheme("catppuccin-latte", NewCatppuccinLatteTheme())
172}