Skip to content

Commit 023ca05

Browse files
committed
refactor(treesitter): reorganize highlights order to follow upstream
1 parent 4ee85c6 commit 023ca05

File tree

1 file changed

+47
-44
lines changed

1 file changed

+47
-44
lines changed

lua/catppuccin/groups/integrations/treesitter.lua

+47-44
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,18 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
1313
end
1414

1515
local colors = { -- Reference: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md
16+
-- Identifiers
17+
["@variable"] = { fg = C.text, style = O.styles.variables or {} }, -- Any variable name that does not have another highlight.
18+
["@variable.builtin"] = { fg = C.red, style = O.styles.properties or {} }, -- Variable names that are defined by the languages, like this or self.
19+
["@variable.parameter"] = { fg = C.maroon, style = O.styles.variables or {} }, -- For parameters of a function.
20+
["@variable.member"] = { fg = C.lavender }, -- For fields.
1621

17-
-- Misc
18-
["@error"] = { link = "Error" },
19-
["@operator"] = { link = "Operator" }, -- For any operator: +, but also -> and * in C.
20-
21-
-- Comment
22-
["@comment"] = { link = "Comment" },
23-
["comment.note"] = { fg = C.base, bg = C.blue },
24-
["comment.warning"] = { fg = C.base, bg = C.yellow },
25-
["comment.error"] = { fg = C.base, bg = C.red },
22+
["@constant"] = { link = "Constant" }, -- For constants
23+
["@constant.builtin"] = { fg = C.peach, style = O.styles.keywords or {} }, -- For constant that are built in the language: nil in Lua.
24+
["@constant.macro"] = { link = "Macro" }, -- For constants that are defined by macros: NULL in C.
2625

27-
-- Punctuation
28-
["@punctuation.delimiter"] = { link = "Delimiter" }, -- For delimiters (e.g. `;` / `.` / `,`).
29-
["@punctuation.bracket"] = { fg = C.overlay2 }, -- For brackets and parenthesis.
30-
["@punctuation.special"] = { link = "Special" }, -- For special punctuation that does not fall in the categories before (e.g. `{}` in string interpolation).
26+
["@module"] = { fg = C.lavender, style = { "italic" } }, -- For identifiers referring to modules and namespaces.
27+
["@label"] = { link = "Label" }, -- For labels: label: in C and :label: in Lua.
3128

3229
-- Literals
3330
["@string"] = { link = "String" }, -- For strings.
@@ -41,74 +38,77 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
4138
["@character.special"] = { link = "SpecialChar" }, -- special characters (e.g. wildcards)
4239

4340
["@boolean"] = { link = "Boolean" }, -- For booleans.
44-
4541
["@number"] = { link = "Number" }, -- For all numbers
4642
["@number.float"] = { link = "Float" }, -- For floats.
4743

44+
-- Types
45+
["@type"] = { link = "Type" }, -- For types.
46+
["@type.builtin"] = { fg = C.yellow, style = O.styles.properties or { "italic" } }, -- For builtin types.
47+
["@type.definition"] = { link = "Type" }, -- type definitions (e.g. `typedef` in C)
48+
["@type.qualifier"] = { link = "Keyword" }, -- type qualifiers (e.g. `const`)
49+
50+
["@attribute"] = { link = "Constant" }, -- attribute annotations (e.g. Python decorators)
51+
["@property"] = { fg = C.lavender, style = O.styles.properties or {} }, -- Same as TSField.
52+
4853
-- Functions
4954
["@function"] = { link = "Function" }, -- For function (calls and definitions).
5055
["@function.builtin"] = { fg = C.peach, style = O.styles.functions or {} }, -- For builtin functions: table.insert in Lua.
5156
["@function.call"] = { link = "Function" }, -- function calls
5257
["@function.macro"] = { fg = C.teal, style = O.styles.functions or {} }, -- For macro defined functions (calls and definitions): each macro_rules in Rust.
58+
5359
["@function.method"] = { link = "Function" }, -- For method definitions.
5460
["@function.method.call"] = { link = "Function" }, -- For method calls.
5561

5662
["@constructor"] = { fg = C.sapphire }, -- For constructor calls and definitions: = { } in Lua, and Java constructors.
63+
["@operator"] = { link = "Operator" }, -- For any operator: +, but also -> and * in C.
5764

5865
-- Keywords
5966
["@keyword"] = { link = "Keyword" }, -- For keywords that don't fall in previous categories.
6067
["@keyword.function"] = { fg = C.mauve, style = O.styles.keywords or {} }, -- For keywords used to define a function.
6168
["@keyword.operator"] = { fg = C.mauve, style = O.styles.operators or {} }, -- For new keyword operator
62-
["@keyword.return"] = { fg = C.mauve, style = O.styles.keywords or {} },
69+
["@keyword.import"] = { link = "Include" }, -- For includes: #include in C, use or extern crate in Rust, or require in Lua.
6370
["@keyword.storage"] = { link = "StorageClass" }, -- visibility/life-time/etc. modifiers (e.g. `static`)
64-
["@keyword.directive"] = { link = "PreProc" }, -- various preprocessor directives & shebangs
65-
["@keyword.directive.define"] = { link = "Define" }, -- preprocessor definition directives
6671
["@keyword.repeat"] = { link = "Repeat" }, -- For keywords related to loops.
72+
["@keyword.return"] = { fg = C.mauve, style = O.styles.keywords or {} },
6773
["@keyword.exception"] = { link = "Exception" }, -- For exception related keywords.
68-
["@keyword.import"] = { link = "Include" }, -- For includes: #include in C, use or extern crate in Rust, or require in Lua.
74+
6975
["@keyword.conditional"] = { link = "Conditional" }, -- For keywords related to conditionnals.
76+
77+
["@keyword.directive"] = { link = "PreProc" }, -- various preprocessor directives & shebangs
78+
["@keyword.directive.define"] = { link = "Define" }, -- preprocessor definition directives
7079
-- JS & derivative
7180
["@keyword.export"] = { fg = C.sky, style = O.styles.keywords },
7281

73-
-- @debug ; keywords related to debugging
74-
["@label"] = { link = "Label" }, -- For labels: label: in C and :label: in Lua.
75-
76-
-- Types
77-
["@type"] = { link = "Type" }, -- For types.
78-
["@type.builtin"] = { fg = C.yellow, style = O.styles.properties or { "italic" } }, -- For builtin types.
79-
["@type.definition"] = { link = "Type" }, -- type definitions (e.g. `typedef` in C)
80-
["@type.qualifier"] = { link = "Keyword" }, -- type qualifiers (e.g. `const`)
81-
82-
["@attribute"] = { link = "Constant" }, -- attribute annotations (e.g. Python decorators)
83-
["@property"] = { fg = C.lavender, style = O.styles.properties or {} }, -- Same as TSField.
84-
85-
-- Identifiers
86-
87-
["@variable"] = { fg = C.text, style = O.styles.variables or {} }, -- Any variable name that does not have another highlight.
88-
["@variable.builtin"] = { fg = C.red, style = O.styles.properties or {} }, -- Variable names that are defined by the languages, like this or self.
89-
["@variable.parameter"] = { fg = C.maroon, style = O.styles.variables or {} }, -- For parameters of a function.
90-
["@variable.member"] = { fg = C.lavender }, -- For fields.
82+
-- Punctuation
83+
["@punctuation.delimiter"] = { link = "Delimiter" }, -- For delimiters (e.g. `;` / `.` / `,`).
84+
["@punctuation.bracket"] = { fg = C.overlay2 }, -- For brackets and parenthesis.
85+
["@punctuation.special"] = { link = "Special" }, -- For special punctuation that does not fall in the categories before (e.g. `{}` in string interpolation).
9186

92-
["@constant"] = { link = "Constant" }, -- For constants
93-
["@constant.builtin"] = { fg = C.peach, style = O.styles.keywords or {} }, -- For constant that are built in the language: nil in Lua.
94-
["@constant.macro"] = { link = "Macro" }, -- For constants that are defined by macros: NULL in C.
87+
-- Comment
88+
["@comment"] = { link = "Comment" },
9589

96-
["@module"] = { fg = C.lavender, style = { "italic" } }, -- For identifiers referring to modules and namespaces.
90+
["comment.error"] = { fg = C.base, bg = C.red },
91+
["comment.warning"] = { fg = C.base, bg = C.yellow },
92+
["comment.note"] = { fg = C.base, bg = C.blue },
9793

98-
-- Text
94+
-- Markup
9995
["@markup"] = { fg = C.text }, -- For strings considerated text in a markup language.
10096
["@markup.strong"] = { fg = C.maroon, style = { "bold" } }, -- bold
10197
["@markup.italic"] = { fg = C.maroon, style = { "italic" } }, -- italic
102-
["@markup.underline"] = { link = "Underline" }, -- underlined text
10398
["@markup.strikethrough"] = { fg = C.text, style = { "strikethrough" } }, -- strikethrough text
99+
["@markup.underline"] = { link = "Underline" }, -- underlined text
100+
104101
["@markup.heading"] = { fg = C.blue, style = { "bold" } }, -- titles like: # Example
105-
["@markup.raw"] = { fg = C.teal }, -- used for inline code in markdown and for doc in python (""")
106-
["@markup.link.url"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
102+
107103
["@markup.math"] = { fg = C.blue }, -- math environments (e.g. `$ ... $` in LaTeX)
108104
["@markup.environment"] = { fg = C.pink }, -- text environments of markup languages
109105
["@markup.environment.name"] = { fg = C.blue }, -- text indicating the type of an environment
106+
107+
["@markup.link.url"] = { fg = C.rosewater, style = { "italic", "underline" } }, -- urls, links and emails
110108
["@markup.link"] = { link = "Tag" }, -- text references, footnotes, citations, etc.
111109

110+
["@markup.raw"] = { fg = C.teal }, -- used for inline code in markdown and for doc in python (""")
111+
112112
["@markup.list"] = { link = "Special" },
113113
["@markup.list.checked"] = { fg = C.green }, -- todo notes
114114
["@markup.list.unchecked"] = { fg = C.overlay1 }, -- todo notes
@@ -123,6 +123,9 @@ If you want to stay on nvim 0.7, either disable the integration or pin catppucci
123123
["@tag.attribute"] = { fg = C.teal, style = { "italic" } }, -- Tags like html tag names.
124124
["@tag.delimiter"] = { fg = C.sky }, -- Tag delimiter like < > /
125125

126+
-- Misc
127+
["@error"] = { link = "Error" },
128+
126129
-- Language specific:
127130
-- bash
128131
["@function.builtin.bash"] = { fg = C.red, style = { "italic" } },

0 commit comments

Comments
 (0)