Skip to content

Commit 421da4a

Browse files
committed
feat(treesitter): follow helix and markup captures
1 parent e7280ea commit 421da4a

File tree

1 file changed

+68
-36
lines changed

1 file changed

+68
-36
lines changed

lua/catppuccin/groups/integrations/treesitter.lua

+68-36
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
1515
local colors = { -- Reference: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md
1616

1717
-- Misc
18-
["@comment"] = { link = "Comment" },
1918
["@error"] = { link = "Error" },
20-
["@preproc"] = { link = "PreProc" }, -- various preprocessor directives & shebangs
2119
["@define"] = { link = "Define" }, -- preprocessor definition directives
2220
["@operator"] = { link = "Operator" }, -- For any operator: +, but also -> and * in C.
2321

22+
-- Comment
23+
["@comment"] = { link = "Comment" },
24+
["comment.note"] = { fg = C.base, bg = C.blue },
25+
["comment.warning"] = { fg = C.base, bg = C.yellow },
26+
["comment.error"] = { fg = C.base, bg = C.red },
27+
2428
-- Punctuation
2529
["@punctuation.delimiter"] = { link = "Delimiter" }, -- For delimiters (e.g. `;` / `.` / `,`).
2630
["@punctuation.bracket"] = { fg = C.overlay2 }, -- For brackets and parenthesis.
@@ -32,6 +36,7 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
3236
["@string.escape"] = { fg = C.pink, style = O.styles.strings or {} }, -- For escape characters within a string.
3337
["@string.special"] = { link = "Special" }, -- other special strings (e.g. dates)
3438
["@string.special.symbol"] = { fg = C.flamingo },
39+
["@string.special.url"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
3540

3641
["@character"] = { link = "Character" }, -- character literals
3742
["@character.special"] = { link = "SpecialChar" }, -- special characters (e.g. wildcards)
@@ -46,8 +51,8 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
4651
["@function.builtin"] = { fg = C.peach, style = O.styles.functions or {} }, -- For builtin functions: table.insert in Lua.
4752
["@function.call"] = { link = "Function" }, -- function calls
4853
["@function.macro"] = { fg = C.teal, style = O.styles.functions or {} }, -- For macro defined functions (calls and definitions): each macro_rules in Rust.
49-
["@method"] = { link = "Function" }, -- For method definitions.
50-
["@method.call"] = { link = "Function" }, -- For method calls.
54+
["@function.method"] = { link = "Function" }, -- For method definitions.
55+
["@function.method.call"] = { link = "Function" }, -- For method calls.
5156

5257
["@constructor"] = { fg = C.sapphire }, -- For constructor calls and definitions: = { } in Lua, and Java constructors.
5358

@@ -56,6 +61,8 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
5661
["@keyword.function"] = { fg = C.mauve, style = O.styles.keywords or {} }, -- For keywords used to define a function.
5762
["@keyword.operator"] = { fg = C.mauve, style = O.styles.operators or {} }, -- For new keyword operator
5863
["@keyword.return"] = { fg = C.mauve, style = O.styles.keywords or {} },
64+
["@keyword.storage"] = { link = "StorageClass" }, -- visibility/life-time/etc. modifiers (e.g. `static`)
65+
["@keyword.directive"] = { link = "PreProc" }, -- various preprocessor directives & shebangs
5966
-- JS & derivative
6067
["@keyword.export"] = { fg = C.sky, style = O.styles.keywords },
6168

@@ -72,16 +79,15 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
7279
["@type.definition"] = { link = "Type" }, -- type definitions (e.g. `typedef` in C)
7380
["@type.qualifier"] = { link = "Keyword" }, -- type qualifiers (e.g. `const`)
7481

75-
["@storageclass"] = { link = "StorageClass" }, -- visibility/life-time/etc. modifiers (e.g. `static`)
7682
["@attribute"] = { link = "Constant" }, -- attribute annotations (e.g. Python decorators)
77-
["@field"] = { fg = C.lavender }, -- For fields.
7883
["@property"] = { fg = C.lavender, style = O.styles.properties or {} }, -- Same as TSField.
7984

8085
-- Identifiers
8186

8287
["@variable"] = { fg = C.text, style = O.styles.variables or {} }, -- Any variable name that does not have another highlight.
8388
["@variable.builtin"] = { fg = C.red, style = O.styles.properties or {} }, -- Variable names that are defined by the languages, like this or self.
8489
["@variable.parameter"] = { fg = C.maroon, style = O.styles.variables or {} }, -- For parameters of a function.
90+
["@variable.member"] = { fg = C.lavender }, -- For fields.
8591

8692
["@constant"] = { link = "Constant" }, -- For constants
8793
["@constant.builtin"] = { fg = C.peach, style = O.styles.keywords or {} }, -- For constant that are built in the language: nil in Lua.
@@ -95,23 +101,22 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
95101
["@markup.emphasis"] = { fg = C.maroon, style = { "italic" } }, -- italic
96102
["@markup.underline"] = { link = "Underline" }, -- underlined text
97103
["@markup.strike"] = { fg = C.text, style = { "strikethrough" } }, -- strikethrough text
98-
["@markup.headline"] = { fg = C.blue, style = { "bold" } }, -- titles like: # Example
104+
["@markup.heading"] = { fg = C.blue, style = { "bold" } }, -- titles like: # Example
99105
["@markup.raw"] = { fg = C.teal }, -- used for inline code in markdown and for doc in python (""")
100-
["@markup.link.uri"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
106+
["@markup.link.url"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
101107
["@markup.math"] = { fg = C.blue }, -- math environments (e.g. `$ ... $` in LaTeX)
102108
["@markup.environment"] = { fg = C.pink }, -- text environments of markup languages
103109
["@markup.environment.name"] = { fg = C.blue }, -- text indicating the type of an environment
104110
["@markup.reference"] = { link = "Tag" }, -- text references, footnotes, citations, etc.
105111

106-
["@markup.todo"] = { fg = C.base, bg = C.yellow }, -- todo notes
107-
["@markup.todo.checked"] = { fg = C.green }, -- todo notes
108-
["@markup.todo.unchecked"] = { fg = C.overlay1 }, -- todo notes
109-
["@markup.note"] = { fg = C.base, bg = C.blue },
110-
["@markup.warning"] = { fg = C.base, bg = C.yellow },
111-
["@markup.danger"] = { fg = C.base, bg = C.red },
112+
["@markup.list"] = { link = "Special" },
113+
["@markup.list.checked"] = { fg = C.green }, -- todo notes
114+
["@markup.list.unchecked"] = { fg = C.overlay1 }, -- todo notes
112115

113-
["@markup.diff.add"] = { link = "diffAdded" }, -- added text (for diff files)
114-
["@markup.diff.delete"] = { link = "diffRemoved" }, -- deleted text (for diff files)
116+
-- Diff
117+
["@diff.plus"] = { link = "diffAdded" }, -- added text (for diff files)
118+
["@diff.minus"] = { link = "diffRemoved" }, -- deleted text (for diff files)
119+
["@diff.delta"] = { link = "diffChanged" }, -- deleted text (for diff files)
115120

116121
-- Tags
117122
["@tag"] = { fg = C.mauve }, -- Tags like html tag names.
@@ -123,12 +128,12 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
123128
["@function.builtin.bash"] = { fg = C.red, style = { "italic" } },
124129

125130
-- markdown
126-
["@text.title.2.markdown"] = { link = "rainbow2" },
127-
["@text.title.1.markdown"] = { link = "rainbow1" },
128-
["@text.title.3.markdown"] = { link = "rainbow3" },
129-
["@text.title.4.markdown"] = { link = "rainbow4" },
130-
["@text.title.5.markdown"] = { link = "rainbow5" },
131-
["@text.title.6.markdown"] = { link = "rainbow6" },
131+
["@markup.heading.1.markdown"] = { link = "rainbow1" },
132+
["@markup.heading.2.markdown"] = { link = "rainbow2" },
133+
["@markup.heading.3.markdown"] = { link = "rainbow3" },
134+
["@markup.heading.4.markdown"] = { link = "rainbow4" },
135+
["@markup.heading.5.markdown"] = { link = "rainbow5" },
136+
["@markup.heading.6.markdown"] = { link = "rainbow6" },
132137

133138
-- java
134139
["@constant.java"] = { fg = C.teal },
@@ -160,14 +165,14 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
160165
["@tag.attribute.tsx"] = { fg = C.mauve, style = { "italic" } },
161166

162167
-- yaml
163-
["@field.yaml"] = { fg = C.blue }, -- For fields.
168+
["@variable.member.yaml"] = { fg = C.blue }, -- For fields.
164169

165170
-- Ruby
166171
["@string.special.symbol.ruby"] = { fg = C.flamingo },
167172

168173
-- PHP
169-
["@method.php"] = { link = "Function" },
170-
["@method.call.php"] = { link = "Function" },
174+
["@function.method.php"] = { link = "Function" },
175+
["@function.method.call.php"] = { link = "Function" },
171176

172177
-- C/CPP
173178
["@type.builtin.c"] = { fg = C.yellow, style = {} },
@@ -181,6 +186,7 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
181186

182187
-- Legacy highlights
183188
colors["@parameter"] = colors["@variable.parameter"]
189+
colors["@field"] = colors["@variable.member"]
184190
colors["@namespace"] = colors["@module"]
185191
colors["@float"] = colors["number.float"]
186192
colors["@symbol"] = colors["@string.special.symbol"]
@@ -191,26 +197,52 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
191197
colors["@text.emphasis"] = colors["@markup.emphasis"]
192198
colors["@text.underline"] = colors["@markup.underline"]
193199
colors["@text.strike"] = colors["@markup.strike"]
194-
colors["@text.title"] = colors["@markup.headline"]
195-
colors["@text.literal"] = colors["@markup.raw"]
196-
colors["@text.uri"] = colors["@markup.link.uri"]
200+
colors["@text.uri"] = colors["@markup.link.url"]
197201
colors["@text.math"] = colors["@markup.math"]
198202
colors["@text.environment"] = colors["@markup.environment"]
199203
colors["@text.environment.name"] = colors["@markup.environment.name"]
204+
205+
colors["@text.title"] = colors["@markup.heading"]
206+
colors["@text.literal"] = colors["@markup.raw"]
200207
colors["@text.reference"] = colors["@markup.reference"]
201208

202-
colors["@text.todo"] = colors["@markup.todo"]
203-
colors["@text.todo.checked"] = colors["@markup.todo.checked"]
204-
colors["@text.todo.unchecked"] = colors["@markup.todo.unchecked"]
205-
colors["@text.note"] = colors["@markup.note"]
206-
colors["@text.warning"] = colors["@markup.warning"]
207-
colors["@text.danger"] = colors["@markup.danger"]
209+
colors["@text.todo.checked"] = colors["@markup.list.checked"]
210+
colors["@text.todo.unchecked"] = colors["@markup.list.unchecked"]
211+
212+
-- @text.todo is now for todo comments, not todo notes like in markdown
213+
colors["@text.todo"] = colors["comment.warning"]
214+
colors["@text.warning"] = colors["comment.warning"]
215+
colors["@text.note"] = colors["comment.note"]
216+
colors["@text.danger"] = colors["comment.error"]
208217

209-
colors["@text.diff.add"] = colors["@markup.diff.add"]
210-
colors["@text.diff.delete"] = colors["@markup.diff.delete"]
218+
-- @text.uri is now
219+
-- @markup.link.uri in markup links
220+
-- @string.special.url outside of markup
221+
colors["text.uri"] = colors["@markup.link.uri"]
222+
223+
colors["@method"] = colors["@function.method"]
224+
colors["@method.call"] = colors["@function.method.call"]
225+
226+
colors["@text.diff.add"] = colors["@diff.plus"]
227+
colors["@text.diff.delete"] = colors["@diff.minus"]
228+
229+
colors["@preproc"] = colors["@keyword.directive"]
230+
colors["@storageclass"] = colors["@keyword.storage"]
211231

212232
colors["@symbol.ruby"] = colors["@string.special.symbol.ruby"]
213233

234+
colors["@variable.member.yaml"] = colors["@field.yaml"]
235+
236+
colors["@text.title.1.markdown"] = colors["@markup.heading.1.markdown"]
237+
colors["@text.title.2.markdown"] = colors["@markup.heading.2.markdown"]
238+
colors["@text.title.3.markdown"] = colors["@markup.heading.3.markdown"]
239+
colors["@text.title.4.markdown"] = colors["@markup.heading.4.markdown"]
240+
colors["@text.title.5.markdown"] = colors["@markup.heading.5.markdown"]
241+
colors["@text.title.6.markdown"] = colors["@markup.heading.6.markdown"]
242+
243+
colors["@method.php"] = colors["@function.method.php"]
244+
colors["@method.call.php"] = colors["@function.method.call.php"]
245+
214246
return colors
215247
end
216248

0 commit comments

Comments
 (0)