Skip to content

Commit ff151e7

Browse files
committed
refactor(syntax)!: reimplement the syntax highlighter
1 parent f36af06 commit ff151e7

File tree

5 files changed

+67
-58
lines changed

5 files changed

+67
-58
lines changed

lua/catppuccin/groups/editor.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ function M.get()
4949
PmenuThumb = { bg = C.overlay0 }, -- Popup menu: Thumb of the scrollbar.
5050
Question = { fg = C.blue }, -- |hit-enter| prompt and yes/no questions
5151
QuickFixLine = { bg = C.surface1, style = { "bold" } }, -- Current |quickfix| item in the quickfix window. Combined with |hl-CursorLine| when the cursor is there.
52-
Search = { bg = U.darken(C.sky, 0.30, C.base), fg = C.text }, -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
53-
IncSearch = { bg = U.darken(C.sky, 0.90, C.base), fg = C.mantle }, -- 'incsearch' highlighting; also used for the text replaced with ":s///c"
52+
Search = { bg = C.surface1, fg = C.pink, style = { "bold" } }, -- Last search pattern highlighting (see 'hlsearch'). Also used for similar items that need to stand out.
53+
IncSearch = { bg = C.pink, fg = C.surface1 }, -- 'incsearch' highlighting; also used for the text replaced with ":s///c"
5454
CurSearch = { bg = C.red, fg = C.mantle }, -- 'cursearch' highlighting: highlights the current search you're on differently
5555
SpecialKey = { fg = C.text }, -- Unprintable characters: text displayed differently from what it really is. But not 'listchars' textspace. |hl-Whitespace|
5656
SpellBad = { sp = C.red, style = { "undercurl" } }, -- Word that is not recognized by the spellchecker. |spell| Combined with the highlighting used otherwise.

lua/catppuccin/groups/integrations/native_lsp.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function M.get()
88
local error = C.red
99
local warning = C.yellow
1010
local info = C.sky
11-
local hint = C.teal
11+
local hint = C.rosewater
1212
local darkening_percentage = 0.095
1313

1414
return {

lua/catppuccin/groups/integrations/semantic_tokens.lua

+17-15
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,37 @@ If you want to stay on nvim 0.7, disable the integration.
1212
return {}
1313
end
1414
return {
15-
["@lsp.type.boolean"] = { link = "@boolean" },
16-
["@lsp.type.builtinType"] = { link = "@type.builtin" },
15+
["@lsp.type.class"] = { link = "@type" },
1716
["@lsp.type.comment"] = { link = "@comment" },
1817
["@lsp.type.enum"] = { link = "@type" },
1918
["@lsp.type.enumMember"] = { link = "@constant" },
2019
["@lsp.type.escapeSequence"] = { link = "@string.escape" },
21-
["@lsp.type.formatSpecifier"] = { link = "@punctuation.special" },
22-
["@lsp.type.interface"] = { fg = C.flamingo },
20+
["@lsp.type.event"] = { link = "@event" },
21+
["@lsp.type.formatSpecifier"] = { link = "@string.special" },
22+
["@lsp.type.interface"] = { link = "@type" },
2323
["@lsp.type.keyword"] = { link = "@keyword" },
24+
["@lsp.type.modifier"] = { link = "@keyword" },
2425
["@lsp.type.namespace"] = { link = "@namespace" },
2526
["@lsp.type.number"] = { link = "@number" },
2627
["@lsp.type.operator"] = { link = "@operator" },
2728
["@lsp.type.parameter"] = { link = "@parameter" },
2829
["@lsp.type.property"] = { link = "@property" },
30+
["@lsp.type.property.cpp"] = { link = "@property.cpp" },
31+
["@lsp.type.regex"] = { link = "@string.regex" },
2932
["@lsp.type.selfKeyword"] = { link = "@variable.builtin" },
30-
["@lsp.type.typeAlias"] = { link = "@type.definition" },
31-
["@lsp.type.unresolvedReference"] = { link = "@error" },
33+
["@lsp.type.struct"] = { link = "@type" },
34+
["@lsp.type.typeParameter.cpp"] = { link = "@parameter" },
3235
["@lsp.type.variable"] = {}, -- use treesitter styles for regular variables
33-
["@lsp.typemod.class.defaultLibrary"] = { link = "@type.builtin" },
34-
["@lsp.typemod.enum.defaultLibrary"] = { link = "@type.builtin" },
35-
["@lsp.typemod.enumMember.defaultLibrary"] = { link = "@constant.builtin" },
36-
["@lsp.typemod.function.defaultLibrary"] = { link = "@function.builtin" },
37-
["@lsp.typemod.keyword.async"] = { link = "@keyword.coroutine" },
38-
["@lsp.typemod.macro.defaultLibrary"] = { link = "@function.builtin" },
39-
["@lsp.typemod.method.defaultLibrary"] = { link = "@function.builtin" },
36+
["@lsp.typemod.enum.defaultLibrary"] = { link = "@type" },
37+
["@lsp.typemod.enumMember.defaultLibrary"] = { link = "@constant" },
38+
["@lsp.typemod.function.defaultLibrary"] = { link = "@function" },
39+
["@lsp.typemod.keyword.async"] = { link = "@keyword" },
40+
["@lsp.typemod.macro.defaultLibrary"] = { link = "@constant.macro" },
41+
["@lsp.typemod.method.defaultLibrary"] = { link = "@function" },
4042
["@lsp.typemod.operator.injected"] = { link = "@operator" },
4143
["@lsp.typemod.string.injected"] = { link = "@string" },
42-
["@lsp.typemod.type.defaultLibrary"] = { link = "@type.builtin" },
43-
["@lsp.typemod.variable.defaultLibrary"] = { link = "@variable.builtin" },
44+
["@lsp.typemod.type.defaultLibrary"] = { link = "@type" },
45+
["@lsp.typemod.variable.defaultLibrary"] = { link = "@variable" },
4446
["@lsp.typemod.variable.injected"] = { link = "@variable" },
4547
}
4648
end

lua/catppuccin/groups/integrations/treesitter.lua

+37-29
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
2222
["@operator"] = { link = "Operator" }, -- For any operator: +, but also -> and * in C.
2323

2424
-- Punctuation
25-
["@punctuation.delimiter"] = { link = "Delimiter" }, -- For delimiters ie: .
25+
["@punctuation.delimiter"] = { link = "Delimiter" }, -- For delimiters (e.g. `;` / `.` / `,`).
2626
["@punctuation.bracket"] = { fg = C.overlay2 }, -- For brackets and parenthesis.
27-
["@punctuation.special"] = { link = "Special" }, -- For special punctutation that does not fall in the categories before.
27+
["@punctuation.special"] = { link = "Special" }, -- For special punctuation that does not fall in the categories before (e.g. `{}` in string interpolation).
2828

2929
-- Literals
3030
["@string"] = { link = "String" }, -- For strings.
@@ -43,21 +43,20 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
4343
["@function"] = { link = "Function" }, -- For function (calls and definitions).
4444
["@function.builtin"] = { fg = C.peach, style = O.styles.functions or {} }, -- For builtin functions: table.insert in Lua.
4545
["@function.call"] = { link = "Function" }, -- function calls
46-
["@function.macro"] = { fg = C.teal, style = O.styles.functions or {} }, -- For macro defined functions (calls and definitions): each macro_rules in RusC.
47-
["@method"] = { link = "Function" }, -- For method calls and definitions.
48-
49-
["@method.call"] = { link = "Function" }, -- method calls
46+
["@function.macro"] = { link = "Constant" }, -- For macro defined functions (calls and definitions): each macro_rules in RusC.
47+
["@method"] = { link = "Function" }, -- For method definitions.
48+
["@method.call"] = { link = "Function" }, -- For method calls.
5049

5150
["@constructor"] = { fg = C.sapphire }, -- For constructor calls and definitions: = { } in Lua, and Java constructors.
52-
["@parameter"] = { fg = C.maroon, style = { "italic" } }, -- For parameters of a function.
51+
["@parameter"] = { fg = C.rosewater, style = O.styles.variables or {} }, -- For parameters of a function.
5352

5453
-- Keywords
5554
["@keyword"] = { link = "Keyword" }, -- For keywords that don't fall in previous categories.
56-
["@keyword.function"] = { fg = C.mauve, style = O.styles.keywords or {} }, -- For keywords used to define a function.
57-
["@keyword.operator"] = { fg = C.mauve, style = O.styles.operators or {} }, -- For new keyword operator
58-
["@keyword.return"] = { fg = C.mauve, style = O.styles.keywords or {} },
55+
["@keyword.function"] = { fg = C.maroon, style = O.styles.keywords or {} }, -- For keywords used to define a function.
56+
["@keyword.operator"] = { link = "Operator" }, -- For new keyword operator
57+
["@keyword.return"] = { fg = C.pink, style = O.styles.keywords or {} },
5958
-- JS & derivative
60-
["@keyword.export"] = { fg = C.sky, style = { "bold" } },
59+
["@keyword.export"] = { fg = C.sky, style = O.styles.keywords },
6160

6261
["@conditional"] = { link = "Conditional" }, -- For keywords related to conditionnals.
6362
["@repeat"] = { link = "Repeat" }, -- For keywords related to loops.
@@ -67,31 +66,28 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
6766
["@exception"] = { link = "Exception" }, -- For exception related keywords.
6867

6968
-- Types
70-
7169
["@type"] = { link = "Type" }, -- For types.
72-
["@type.builtin"] = { fg = C.yellow, style = O.styles.properties or "italic" }, -- For builtin types.
73-
["@type.definition"] = { link = "@type" }, -- type definitions (e.g. `typedef` in C)
74-
["@type.qualifier"] = { link = "@type" }, -- type qualifiers (e.g. `const`)
70+
["@type.builtin"] = { fg = C.yellow, style = O.styles.properties or { "italic" } }, -- For builtin types.
71+
["@type.definition"] = { link = "Type" }, -- type definitions (e.g. `typedef` in C)
72+
["@type.qualifier"] = { link = "Keyword" }, -- type qualifiers (e.g. `const`)
7573

7674
["@storageclass"] = { link = "StorageClass" }, -- visibility/life-time/etc. modifiers (e.g. `static`)
7775
["@attribute"] = { link = "Constant" }, -- attribute annotations (e.g. Python decorators)
78-
["@field"] = { fg = C.lavender }, -- For fields.
79-
["@property"] = { fg = C.lavender, style = O.styles.properties or {} }, -- Same as TSField.
76+
["@field"] = { fg = C.rosewater }, -- For fields.
77+
["@property"] = { fg = C.rosewater, style = O.styles.properties or {} }, -- Same as TSField.
8078

8179
-- Identifiers
82-
83-
["@variable"] = { fg = C.text, style = O.styles.variables or {} }, -- Any variable name that does not have another highlight.
84-
["@variable.builtin"] = { fg = C.red }, -- Variable names that are defined by the languages, like this or self.
80+
["@variable"] = { link = "Identifier" }, -- Any variable name that does not have another highlight.
81+
["@variable.builtin"] = { fg = C.red, style = O.styles.properties or {} }, -- Variable names that are defined by the languages, like this or self.
8582

8683
["@constant"] = { link = "Constant" }, -- For constants
87-
["@constant.builtin"] = { fg = C.peach, style = O.styles.keywords or {} }, -- For constant that are built in the language: nil in Lua.
84+
["@constant.builtin"] = { fg = C.lavender, style = O.styles.properties or {} }, -- For constant that are built in the language: nil in Lua.
8885
["@constant.macro"] = { link = "Macro" }, -- For constants that are defined by macros: NULL in C.
8986

90-
["@namespace"] = { fg = C.lavender, style = { "italic" } }, -- For identifiers referring to modules and namespaces.
87+
["@namespace"] = { fg = C.rosewater }, -- For identifiers referring to modules and namespaces.
9188
["@symbol"] = { fg = C.flamingo },
9289

9390
-- Text
94-
9591
["@text"] = { fg = C.text }, -- For strings considerated text in a markup language.
9692
["@text.strong"] = { fg = C.maroon, style = { "bold" } }, -- bold
9793
["@text.emphasis"] = { fg = C.maroon, style = { "italic" } }, -- italic
@@ -103,7 +99,7 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
10399
["@text.math"] = { fg = C.blue }, -- math environments (e.g. `$ ... $` in LaTeX)
104100
["@text.environment"] = { fg = C.pink }, -- text environments of markup languages
105101
["@text.environment.name"] = { fg = C.blue }, -- text indicating the type of an environment
106-
["@text.reference"] = { fg = C.lavender, style = { "bold" } }, -- references
102+
["@text.reference"] = { link = "Tag" }, -- text references, footnotes, citations, etc.
107103

108104
["@text.todo"] = { fg = C.base, bg = C.yellow }, -- todo notes
109105
["@text.todo.checked"] = { fg = C.green }, -- todo notes
@@ -121,6 +117,8 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
121117
["@tag.delimiter"] = { fg = C.sky }, -- Tag delimiter like < > /
122118

123119
-- Language specific:
120+
-- bash
121+
["@function.builtin.bash"] = { fg = C.red, style = { "italic" } },
124122

125123
-- markdown
126124
["@text.title.2.markdown"] = { link = "rainbow2" },
@@ -139,35 +137,45 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
139137
["@string.plain.css"] = { fg = C.peach },
140138
["@number.css"] = { fg = C.peach },
141139

140+
-- java
141+
["@constant.java"] = { fg = C.teal },
142+
142143
-- toml
143144
["@property.toml"] = { fg = C.blue }, -- Differentiates between string and properties
144145

145146
-- json
146147
["@label.json"] = { fg = C.blue }, -- For labels: label: in C and :label: in Lua.
147148

148149
-- lua
149-
["@constructor.lua"] = { fg = C.flamingo }, -- For constructor calls and definitions: = { } in Lua, and Java constructors.
150+
["@constructor.lua"] = { fg = C.flamingo }, -- For constructor calls and definitions: = { } in Lua.
151+
["@field.lua"] = { fg = C.lavender },
150152

151153
-- typescript
154+
["@property.typescript"] = { fg = C.lavender, style = O.styles.properties or {} },
152155
["@constructor.typescript"] = { fg = C.lavender },
153156

154157
-- TSX (Typescript React)
155158
["@constructor.tsx"] = { fg = C.lavender },
156159
["@tag.attribute.tsx"] = { fg = C.mauve, style = { "italic" } },
157160

158-
-- cpp
159-
["@property.cpp"] = { fg = C.rosewater },
160-
161161
-- yaml
162162
["@field.yaml"] = { fg = C.blue }, -- For fields.
163163

164164
-- Ruby
165165
["@symbol.ruby"] = { fg = C.flamingo },
166166

167167
-- PHP
168-
["@type.qualifier.php"] = { link = "Keyword" }, -- type qualifiers (e.g. `const`)
169168
["@method.php"] = { link = "Function" },
170169
["@method.call.php"] = { link = "Function" },
170+
171+
-- C/CPP
172+
["@type.builtin.c"] = { style = {} },
173+
["@property.cpp"] = { fg = C.text },
174+
["@type.builtin.cpp"] = { style = {} },
175+
176+
-- Misc
177+
gitcommitSummary = { fg = C.rosewater, style = { "italic" } },
178+
zshKSHFunction = { link = "Function" },
171179
}
172180
end
173181

lua/catppuccin/groups/syntax.lua

+10-11
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,30 @@ function M.get()
1010
Number = { fg = C.peach, style = O.styles.numbers or {} }, -- a number constant: 234, 0xff
1111
Float = { link = "Number" }, -- a floating point constant: 2.3e10
1212
Boolean = { fg = C.peach, style = O.styles.booleans or {} }, -- a boolean constant: TRUE, false
13-
Identifier = { fg = C.flamingo, style = O.styles.variables or {} }, -- (preferred) any variable name
13+
Identifier = { fg = C.text, style = O.styles.variables or {} }, -- (preferred) any variable name
1414
Function = { fg = C.blue, style = O.styles.functions or {} }, -- function name (also: methods for classes)
1515
Statement = { fg = C.mauve }, -- (preferred) any statement
1616
Conditional = { fg = C.mauve, style = O.styles.conditionals or {} }, -- if, then, else, endif, switch, etc.
1717
Repeat = { fg = C.mauve, style = O.styles.loops or {} }, -- for, do, while, etc.
18-
Label = { fg = C.sapphire }, -- case, default, etc.
18+
Label = { fg = C.rosewater }, -- case, default, etc.
1919
Operator = { fg = C.sky, style = O.styles.operators or {} }, -- "sizeof", "+", "*", etc.
20-
Keyword = { fg = C.mauve, style = O.styles.keywords or {} }, -- any other keyword
21-
Array = { fg = C.lavender },
22-
Exception = { fg = C.mauve, style = O.styles.keywords or {} }, -- try, catch, throw
20+
Keyword = { fg = C.maroon, style = O.styles.keywords or {} }, -- any other keyword
21+
Exception = { fg = C.peach, style = O.styles.keywords or {} }, -- try, catch, throw
2322

2423
PreProc = { fg = C.pink }, -- (preferred) generic Preprocessor
25-
Include = { fg = C.mauve, style = O.styles.keywords or {} }, -- preprocessor #include
24+
Include = { fg = C.teal, style = O.styles.keywords or {} }, -- preprocessor #include
2625
Define = { link = "PreProc" }, -- preprocessor #define
27-
Macro = { fg = C.mauve }, -- same as Define
26+
Macro = { link = "Constant" }, -- same as Define
2827
PreCondit = { link = "PreProc" }, -- preprocessor #if, #else, #endif, etc.
2928

30-
StorageClass = { fg = C.yellow }, -- static, register, volatile, etc.
31-
Structure = { fg = C.yellow }, -- struct, union, enum, etc.
29+
StorageClass = { link = "Keyword" }, -- static, register, volatile, etc.
30+
Structure = { link = "Keyword" }, -- struct, union, enum, etc.
3231
Special = { fg = C.pink }, -- (preferred) any special symbol
3332
Type = { fg = C.yellow, style = O.styles.types or {} }, -- (preferred) int, long, char, etc.
3433
Typedef = { link = "Type" }, -- A typedef
3534
SpecialChar = { link = "Special" }, -- special character in a constant
36-
Tag = { link = "Special" }, -- you can use CTRL-] on this
37-
Delimiter = { fg = C.overlay2 }, -- character that needs attention
35+
Tag = { fg = C.lavender, style = { "bold" } }, -- you can use CTRL-] on this
36+
Delimiter = { fg = C.teal }, -- delimiters (e.g. `;` / `.` / `,`)
3837
Debug = { link = "Special" }, -- debugging statements
3938

4039
Underlined = { style = { "underline" } }, -- (preferred) text that stands out, HTML links

0 commit comments

Comments
 (0)