Skip to content

Commit 6c8ee1d

Browse files
committed
refactor(catppuccin): reimplement basic hl groups
This commit reimplemented basic hl groups and link Treesitter's highlights to these basic hl groups to reduce maintenance pressure
1 parent 9189c59 commit 6c8ee1d

File tree

1 file changed

+84
-56
lines changed

1 file changed

+84
-56
lines changed

lua/modules/configs/ui/catppuccin.lua

+84-56
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
return function()
22
local transparent_background = false -- Set background transparency here!
3+
local clear = {}
34

45
require("catppuccin").setup({
56
flavour = "mocha", -- Can be one of: latte, frappe, macchiato, mocha
@@ -119,19 +120,17 @@ return function()
119120
},
120121
},
121122
highlight_overrides = {
123+
---@param cp palette
122124
mocha = function(cp)
123125
return {
124-
-- For base configs.
126+
-- For base configs
125127
NormalFloat = { fg = cp.text, bg = transparent_background and cp.none or cp.base },
128+
-- FloatBorder = { fg = cp.blue },
126129
CursorLineNr = { fg = cp.green },
127130
Search = { bg = cp.surface1, fg = cp.pink, style = { "bold" } },
128131
IncSearch = { bg = cp.pink, fg = cp.surface1 },
129-
Keyword = { fg = cp.pink },
130-
Type = { fg = cp.blue },
131-
Typedef = { fg = cp.yellow },
132-
StorageClass = { fg = cp.red, style = { "italic" } },
133132

134-
-- For native lsp configs.
133+
-- For native lsp configs
135134
DiagnosticVirtualTextError = { bg = cp.none },
136135
DiagnosticVirtualTextWarn = { bg = cp.none },
137136
DiagnosticVirtualTextInfo = { bg = cp.none },
@@ -143,95 +142,121 @@ return function()
143142
LspDiagnosticsVirtualTextHint = { fg = cp.rosewater },
144143
LspDiagnosticsUnderlineHint = { sp = cp.rosewater },
145144

146-
-- For fidget.
145+
-- For fidget
147146
FidgetTask = { bg = cp.none, fg = cp.surface2 },
148147
FidgetTitle = { fg = cp.blue, style = { "bold" } },
149148

149+
-- For nvim-tree
150+
NvimTreeRootFolder = { fg = cp.pink },
151+
150152
-- For trouble.nvim
151153
TroubleNormal = { bg = cp.base },
152154

153155
-- For lsp semantic tokens
154156
["@lsp.type.comment"] = { fg = cp.overlay0 },
155157
["@lsp.type.enum"] = { link = "@type" },
158+
["@lsp.type.type"] = { link = "@type" },
156159
["@lsp.type.property"] = { link = "@property" },
160+
["@lsp.type.property.c"] = { link = "@property.cpp" },
161+
["@lsp.type.property.cpp"] = { link = "@property.cpp" },
157162
["@lsp.type.macro"] = { link = "@constant" },
158163
["@lsp.typemod.function.defaultLibrary"] = { fg = cp.blue, style = { "bold", "italic" } },
159164
["@lsp.typemod.function.defaultLibrary.c"] = { fg = cp.blue, style = { "bold" } },
160165
["@lsp.typemod.function.defaultLibrary.cpp"] = { fg = cp.blue, style = { "bold" } },
161166
["@lsp.typemod.method.defaultLibrary"] = { link = "@lsp.typemod.function.defaultLibrary" },
162167
["@lsp.typemod.variable.defaultLibrary"] = { fg = cp.flamingo },
163168

164-
-- For treesitter.
165-
["@field"] = { fg = cp.rosewater },
166-
["@property"] = { fg = cp.yellow },
169+
-- For treesitter
170+
-- Comment = { fg = cp.overlay0 },
171+
-- Error = { fg = cp.red },
172+
-- PreProc = { fg = cp.pink },
173+
-- Operator = { fg = cp.sky },
167174

168-
["@include"] = { fg = cp.teal },
169-
-- ["@operator"] = { fg = cp.sky },
170-
["@keyword.operator"] = { fg = cp.sky },
175+
["@punctuation.delimiter"] = { fg = cp.teal },
176+
["@punctuation.bracket"] = { fg = cp.overlay2 },
171177
["@punctuation.special"] = { fg = cp.maroon },
172178

173-
-- ["@float"] = { fg = cp.peach },
174-
-- ["@number"] = { fg = cp.peach },
175-
-- ["@boolean"] = { fg = cp.peach },
179+
-- String = { fg = cp.green },
180+
-- ["@string.regex"] = { fg = cp.peach },
181+
-- ["@string.escape"] = { fg = cp.pink },
182+
-- ["@string.special"] = { fg = cp.blue },
183+
184+
-- Character = { fg = cp.teal },
185+
-- SpecialChar = { link = "Special" },
186+
187+
-- Boolean = { fg = cp.peach },
188+
-- Number = { fg = cp.peach },
189+
190+
-- Function = { fg = cp.blue },
191+
-- ["@function.builtin"] = { fg = cp.peach },
192+
-- ["@function.call"] = { link = "@function" },
193+
-- ["@function.macro"] = { fg = cp.teal },
194+
["@method"] = { link = "Function" },
195+
-- ["@method.call"] = { link = "@method" },
176196

177197
["@constructor"] = { fg = cp.lavender },
178-
-- ["@constant"] = { fg = cp.peach },
179-
-- ["@conditional"] = { fg = cp.mauve },
180-
-- ["@repeat"] = { fg = cp.mauve },
198+
["@parameter"] = { fg = cp.rosewater },
199+
200+
Keyword = { fg = cp.red },
201+
["@keyword.function"] = { fg = cp.maroon },
202+
["@keyword.operator"] = { fg = cp.sky },
203+
["@keyword.return"] = { fg = cp.pink, style = clear },
204+
-- ["@keyword.export"] = { fg = cp.sky },
205+
206+
Conditional = { fg = cp.mauve },
207+
Repeat = { fg = cp.mauve },
208+
Label = { fg = cp.rosewater },
209+
["@include"] = { fg = cp.teal },
181210
["@exception"] = { fg = cp.peach },
182211

183-
["@constant.builtin"] = { fg = cp.lavender },
184-
-- ["@function.builtin"] = { fg = cp.peach, style = { "italic" } },
185-
-- ["@type.builtin"] = { fg = cp.yellow, style = { "italic" } },
212+
-- Type = { fg = cp.yellow },
213+
-- ["@type.builtin"] = { fg = cp.yellow },
214+
-- ["@type.definition"] = { link = "@type" },
186215
["@type.qualifier"] = { link = "@keyword" },
187-
["@variable.builtin"] = { fg = cp.red, style = { "italic" } },
188216

189-
-- ["@function"] = { fg = cp.blue },
190-
["@function.macro"] = { fg = cp.red, style = {} },
191-
["@parameter"] = { fg = cp.rosewater },
192-
["@keyword"] = { fg = cp.red, style = { "italic" } },
193-
["@keyword.function"] = { fg = cp.maroon },
194-
["@keyword.return"] = { fg = cp.pink, style = {} },
217+
StorageClass = { link = "@keyword" },
218+
-- Constant = { fg = cp.peach },
219+
["@field"] = { fg = cp.rosewater },
220+
["@property"] = { fg = cp.yellow },
195221

196-
-- ["@text.note"] = { fg = cp.base, bg = cp.blue },
197-
-- ["@text.warning"] = { fg = cp.base, bg = cp.yellow },
198-
-- ["@text.danger"] = { fg = cp.base, bg = cp.red },
199-
-- ["@constant.macro"] = { fg = cp.mauve },
222+
-- ["@variable"] = { fg = cp.text },
223+
["@variable.builtin"] = { fg = cp.flamingo, style = { "italic" } },
200224

201-
-- ["@label"] = { fg = cp.blue },
202-
["@method"] = { fg = cp.blue, style = { "italic" } },
203-
["@namespace"] = { fg = cp.rosewater, style = {} },
225+
["@constant"] = { link = "Constant" },
226+
["@constant.builtin"] = { fg = cp.lavender },
227+
Macro = { fg = cp.mauve },
204228

205-
["@punctuation.delimiter"] = { fg = cp.teal },
206-
["@punctuation.bracket"] = { fg = cp.overlay2 },
207-
-- ["@string"] = { fg = cp.green },
208-
-- ["@string.regex"] = { fg = cp.peach },
209-
["@type"] = { fg = cp.yellow },
210-
["@variable"] = { fg = cp.text },
211-
["@tag.attribute"] = { fg = cp.mauve, style = { "italic" } },
229+
["@namespace"] = { fg = cp.rosewater, style = clear },
230+
-- ["@symbol"] = { fg = cp.flamingo },
231+
232+
["@text"] = { fg = cp.text },
212233
["@tag"] = { fg = cp.peach },
234+
["@tag.attribute"] = { fg = cp.mauve },
213235
["@tag.delimiter"] = { fg = cp.maroon },
214-
["@text"] = { fg = cp.text },
215236

216-
-- ["@text.uri"] = { fg = cp.rosewater, style = { "italic", "underline" } },
217-
-- ["@text.literal"] = { fg = cp.teal, style = { "italic" } },
218-
-- ["@text.reference"] = { fg = cp.lavender, style = { "bold" } },
219-
-- ["@text.title"] = { fg = cp.blue, style = { "bold" } },
220-
-- ["@text.emphasis"] = { fg = cp.maroon, style = { "italic" } },
221-
-- ["@text.strong"] = { fg = cp.maroon, style = { "bold" } },
222-
-- ["@string.escape"] = { fg = cp.pink },
237+
-- TODO: support semantic tokens
238+
239+
-- ["@class"] = { fg = cp.blue },
240+
-- ["@struct"] = { fg = cp.blue },
241+
["@enum"] = { link = "@type" },
242+
-- ["@enumMember"] = { fg = cp.flamingo },
243+
-- ["@event"] = { fg = cp.flamingo },
244+
["@interface"] = { fg = cp.yellow },
245+
-- ["@modifier"] = { fg = cp.flamingo },
246+
-- ["@regexp"] = { fg = cp.pink },
247+
-- ["@typeParameter"] = { fg = cp.yellow },
248+
-- ["@decorator"] = { fg = cp.flamingo },
223249

224250
-- ["@property.toml"] = { fg = cp.blue },
225251
-- ["@field.yaml"] = { fg = cp.blue },
226252

227253
-- ["@label.json"] = { fg = cp.blue },
228254

229255
["@function.builtin.bash"] = { fg = cp.red, style = { "italic" } },
230-
["@parameter.bash"] = { fg = cp.yellow, style = { "italic" } },
256+
-- ["@parameter.bash"] = { fg = cp.yellow, style = { "italic" } },
231257

232-
["@field.lua"] = { fg = cp.lavender },
233258
["@constructor.lua"] = { fg = cp.flamingo },
234-
["@variable.builtin.lua"] = { fg = cp.flamingo, style = { "italic" } },
259+
["@field.lua"] = { fg = cp.lavender },
235260

236261
["@constant.java"] = { fg = cp.teal },
237262

@@ -244,12 +269,15 @@ return function()
244269
["@type.css"] = { fg = cp.lavender },
245270
["@property.css"] = { fg = cp.yellow, style = { "italic" } },
246271

247-
["@type.builtin.c"] = { fg = cp.yellow, style = {} },
272+
["@type.builtin.c"] = { style = clear },
248273

249274
["@property.cpp"] = { fg = cp.text },
250-
["@type.builtin.cpp"] = { fg = cp.yellow, style = {} },
275+
["@type.builtin.cpp"] = { style = clear },
251276

252277
-- ["@symbol"] = { fg = cp.flamingo },
278+
279+
-- Misc
280+
gitcommitSummary = { fg = cp.rosewater, style = { "italic" } },
253281
}
254282
end,
255283
},

0 commit comments

Comments
 (0)