Skip to content

Commit b37ac47

Browse files
authored
fix(treesitter): update treesitter to use new highlight naming scheme (#105)
1 parent 3aae080 commit b37ac47

File tree

1 file changed

+195
-108
lines changed

1 file changed

+195
-108
lines changed

lua/astrotheme/groups/plugins/nvim-treesitter.lua

Lines changed: 195 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,146 +1,140 @@
11
---@type AstroThemeCallback
22
local function callback(opts)
33
return {
4+
-- identifiers
5+
["@variable"] = { link = "Identifier" },
6+
["@variable.builtin"] = {
7+
fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.cyan,
8+
bold = opts.simple_syntax_colors,
9+
},
10+
["@variable.parameter"] = {
11+
fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.orange,
12+
},
13+
["@variable.member"] = {
14+
fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.red,
15+
},
416

5-
-- misc
6-
["@comment"] = { link = "Comment" },
7-
["@comment.documentation"] = { link = "@comment" },
8-
["@error"] = { link = "Error" },
9-
["@none"] = { link = "@Comment" },
10-
["@preproc"] = { link = "PreProc" },
11-
["@define"] = { link = "Define" },
12-
["@operator"] = { link = "Operator" },
17+
["@constant"] = { link = "Constant" },
18+
["@constant.builtin"] = { link = "@constant" },
19+
["@constant.macro"] = { link = "@constant" },
1320

14-
-- punctuation
15-
["@punctuation.bracket"] = { fg = C.syntax.text },
16-
["@punctuation.delimiter"] = { fg = C.syntax.text },
17-
["@punctuation.special"] = { link = "Special" },
21+
["@module"] = { link = "Keyword" },
22+
["@module.builtin"] = { fg = C.syntax.yellow },
23+
["@label"] = { link = "Label" },
1824

1925
-- literals
2026
["@string"] = { link = "String" },
27+
["@string.documentation"] = { link = "String" },
28+
["@string.regexp"] = { link = "String" },
2129
["@string.escape"] = { fg = C.syntax.red },
22-
["@string.regex"] = { link = "String" },
2330
["@string.special"] = { link = "String" },
31+
["@string.special.symbol"] = { link = "String" },
32+
["@string.special.url"] = { link = "@markup.link.url" },
33+
["@string.special.path"] = { link = "String" },
2434

2535
["@character"] = { link = "Character" },
2636
["@character.special"] = { link = "SpecialChar" },
2737

2838
["@boolean"] = { link = "Boolean" },
2939
["@number"] = { link = "Number" },
30-
["@float"] = { link = "Float" },
40+
["@number.float"] = { link = "Float" },
41+
42+
-- types
43+
["@type"] = { link = "Type" },
44+
["@type.builtin"] = { link = "@type" },
45+
["@type.definition"] = { link = "@type" },
46+
["@type.qualifier"] = { link = "@type" },
47+
48+
["@attribute"] = { fg = C.syntax.yellow },
49+
["@property"] = { fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.red },
3150

3251
-- function
3352
["@function"] = { link = "Function" },
3453
["@function.builtin"] = { fg = opts.simple_syntax_colors and C.syntax.blue or C.syntax.cyan },
3554
["@function.call"] = { link = "@function" },
3655
["@function.macro"] = { fg = C.syntax.yellow },
3756

38-
["@method"] = { link = "@function" },
39-
["@method.call"] = { link = "@method" },
57+
["@function.method"] = { link = "@function" },
58+
["@function.method.call"] = { link = "@function.method" },
4059

4160
["@constructor"] = { link = "@function" },
42-
["@parameter"] = {
43-
fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.orange,
44-
-- italic = opts.simple_syntax_colors,
45-
},
61+
["@operator"] = { link = "Operator" },
4662

4763
-- keyword
4864
["@keyword"] = { link = "Keyword" },
4965
["@keyword.corotine"] = { link = "Keyword" },
5066
["@keyword.function"] = { link = "Keyword" },
5167
["@keyword.operator"] = { link = "Keyword" },
68+
["@keyword.import"] = { link = "Include" },
69+
["@keyword.storage"] = { link = "StorageClass" },
70+
["@keyword.repeat"] = { link = "Repeat" },
5271
["@keyword.return"] = { link = "Keyword" },
53-
["@keyword.export"] = { link = "Keyword" },
72+
["@keyword.debug"] = { link = "Debug" },
73+
["@keyword.exception"] = { link = "Exception" },
5474

55-
["@conditional"] = { link = "Conditional" },
56-
["@conditional.ternary"] = { link = "@conditional" },
75+
["@keyword.conditional"] = { link = "Conditional" },
76+
["@keyword.conditional.ternary"] = { link = "@keyword.conditional" },
5777

58-
["@repeat"] = { link = "Repeat" },
59-
["@debug"] = { link = "Debug" },
60-
["@label"] = { link = "Label" },
61-
["@include"] = { link = "Include" },
62-
["@exception"] = { link = "Exception" },
78+
["@keyword.directive"] = { link = "Keyword" },
79+
["@keyword.directive.define"] = { link = "Keyword" },
6380

64-
-- types
65-
["@type"] = { link = "Type" },
66-
["@type.builtin"] = { link = "@type" },
67-
["@type.definition"] = { link = "@type" },
68-
["@type.qualifier"] = { link = "@type" },
81+
-- punctuation
82+
["@punctuation.delimiter"] = { fg = C.syntax.text },
83+
["@punctuation.bracket"] = { fg = C.syntax.text },
84+
["@punctuation.special"] = { fg = C.syntax.text },
6985

70-
["@storageclass"] = { link = "StorageClass" },
71-
["@attribute"] = { fg = C.syntax.yellow },
72-
["@field"] = {
73-
fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.red,
74-
},
75-
["@property"] = { fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.red },
86+
-- comment
87+
["@comment"] = { link = "Comment" },
88+
["@comment.documentation"] = { link = "@comment" },
7689

77-
-- identifiers
78-
["@variable"] = { link = "Identifier" },
79-
["@variable.builtin"] = {
80-
fg = opts.simple_syntax_colors and C.syntax.text or C.syntax.cyan,
81-
bold = opts.simple_syntax_colors,
82-
},
90+
["@comment.error"] = { fg = C.ui.base, bg = C.ui.red },
91+
["@cooment.warning"] = { fg = C.ui.base, bg = C.ui.orange },
92+
["@comment.hint"] = { fg = C.ui.base, bg = C.ui.blue },
93+
["@comment.info"] = { fg = C.ui.base, bg = C.ui.cyan },
94+
["@comment.todo"] = { fg = C.ui.base, bg = C.ui.yellow },
8395

84-
["@constant"] = { link = "Constant" },
85-
["@constant.builtin"] = { link = "@constant" },
86-
["@constant.macro"] = { link = "@constant" },
96+
-- markup
97+
["@markup.strong"] = { fg = C.syntax.text, bold = true },
98+
["@markup.italic"] = { fg = C.syntax.text, italic = true },
99+
["@markup.strikethrough"] = { fg = C.syntax.text, strikethrough = true },
100+
["@markup.underline"] = { link = "Underline" },
87101

88-
["@namespace"] = { link = "Keyword" },
89-
["@namespace.builtin"] = { fg = C.syntax.yellow },
90-
["@symbol"] = { link = "Special" },
102+
["@markup.heading"] = { fg = C.syntax.text, bold = true },
103+
["@markup.heading.1.markdown"] = { fg = C.syntax.purple, bold = true },
104+
["@markup.heading.2.markdown"] = { fg = C.syntax.blue, bold = true },
105+
["@markup.heading.3.markdown"] = { fg = C.syntax.cyan, bold = true },
106+
["@markup.heading.4.markdown"] = { fg = C.syntax.green, bold = true },
107+
["@markup.heading.5.markdown"] = { fg = C.syntax.yellow, bold = true },
91108

92-
-- text
93-
["@text"] = { fg = C.syntax.text },
94-
["@text.strong"] = { fg = C.syntax.blue, bold = true },
95-
["@text.emphasis"] = { fg = C.syntax.purple, italic = true },
96-
["@text.underline"] = { link = "Underline" },
97-
["@text.strike"] = { fg = C.syntax.green, strikethrough = true },
98-
["@text.title"] = { fg = C.syntax.text, bold = true },
99-
["@text.title.1.markdown"] = { fg = C.syntax.purple, bold = true },
100-
["@text.title.2.markdown"] = { fg = C.syntax.blue, bold = true },
101-
["@text.title.3.markdown"] = { fg = C.syntax.cyan, bold = true },
102-
["@text.title.4.markdown"] = { fg = C.syntax.green, bold = true },
103-
["@text.title.5.markdown"] = { fg = C.syntax.yellow, bold = true },
104-
["@text.literal"] = { fg = C.syntax.text },
105-
["@text.quote"] = { fg = C.syntax.text, italic = true },
106-
["@text.uri"] = { fg = C.syntax.green, italic = true, underline = true },
107-
["@text.math"] = { fg = C.syntax.blue },
108-
["@text.environment"] = { fg = C.syntax.orange },
109-
["@text.environment.name"] = { fg = C.syntax.blue },
110-
["@text.reference"] = { fg = C.syntax.yellow, bold = true },
111-
112-
["@text.todo"] = { fg = C.ui.base, bg = C.ui.yellow },
113-
["@text.note"] = { fg = C.ui.base, bg = C.ui.blue },
114-
["@text.todo.note"] = { link = "@text.note" },
115-
["@text.warning"] = { fg = C.ui.base, bg = C.ui.orange },
116-
["@text.todo.warning"] = { link = "@text.warning" },
117-
["@text.danger"] = { fg = C.ui.base, bg = C.ui.red },
118-
["@text.todo.danger"] = { link = "@text.danger" },
119-
["@text.unchecked"] = { fg = C.ui.base, bg = C.ui.purple },
120-
["@text.todo.unchecked"] = { link = "@text.unchecked" },
121-
["@text.checked"] = { fg = C.ui.base, bg = C.ui.green },
122-
["@text.todo.checked"] = { link = "@text.checked" },
109+
["@markup.quote"] = { fg = C.syntax.text, italic = true },
110+
["@markup.math"] = { fg = C.syntax.blue },
111+
["@markup.environment"] = { fg = C.syntax.orange },
123112

124-
["@text.diff.add"] = { link = "DiffAdded" },
125-
["@text.diff.delete"] = { link = "DiffDelete" },
113+
["@markup.link"] = { fg = C.syntax.yellow, bold = true },
114+
["@markup.link.label"] = { link = "String" },
115+
["@markup.link.url"] = { fg = C.syntax.green, italic = true, underline = true },
116+
117+
["@markup.raw"] = { fg = C.syntax.text },
118+
["@markup.raw.block"] = { fg = C.syntax.text },
119+
120+
["@markup.list"] = { link = "Special" },
121+
["@markup.list.unchecked"] = { fg = C.ui.base, bg = C.ui.purple },
122+
["@markup.list.checked"] = { fg = C.ui.base, bg = C.ui.green },
123+
124+
["@diff.plus"] = { link = "DiffAdded" },
125+
["@diff.minus"] = { link = "DiffDelete" },
126+
["@diff.delta"] = { link = "DiffChange" },
126127

127-
-- tag
128128
["@tag"] = { fg = C.syntax.red },
129129
["@tag.attribute"] = { fg = C.syntax.cyan },
130130
["@tag.delimiter"] = { fg = C.syntax.text },
131131

132-
-- semantic tokens
133-
["@annotation"] = { fg = C.syntax.yellow },
134-
["@class"] = { fg = C.syntax.blue },
135-
["@decorator"] = { fg = C.syntax.orange },
136-
["@enum"] = { fg = C.syntax.cyan },
137-
["@enumMember"] = { fg = C.syntax.orange },
138-
["@event"] = { fg = C.syntax.orange },
139-
["@interface"] = { fg = C.syntax.orange },
140-
["@modifier"] = { fg = C.syntax.orange },
141-
["@regexp"] = { fg = C.syntax.cyan },
142-
["@struct"] = { fg = C.syntax.blue },
143-
["@typeParameter"] = { fg = C.syntax.yellow },
132+
-- None-highlighting captures
133+
-- ["@none"] = {},
134+
-- ["@conceal"] = {},
135+
136+
-- ["@spell"] = {},
137+
-- ["@nospell"] = {},
144138

145139
-----------------------
146140
-- Language Specific --
@@ -165,25 +159,18 @@ local function callback(opts)
165159
["@constructor.lua"] = { fg = C.syntax.orange },
166160
["@variable.lua"] = { link = "@variable" },
167161

168-
-- markdown
169-
["@literal.markdown"] = { fg = C.syntax.green },
170-
["@none.markdown"] = { fg = C.syntax.text },
171-
["@punctuation.delimiter.markdown"] = { fg = C.syntax.text },
172-
["@punctuation.special.markdown"] = { fg = C.syntax.red },
173-
["@title.markdown"] = { fg = C.syntax.red, bold = true },
174-
175162
-- PHP
176163
["@type.qualifier.php"] = { link = "Keyword" },
177-
["@method.php"] = { link = "Function" },
178-
["@method.call.php"] = { link = "Function" },
164+
["@function.method.php"] = { link = "Function" },
165+
["@function.method.call.php"] = { link = "Function" },
179166

180167
-- Ruby
181-
["@symbol.ruby"] = { fg = C.syntax.orange },
168+
["@string.special.symbol.ruby"] = { fg = C.syntax.orange },
182169

183170
-- rust
184171
["@constant.rust"] = { fg = C.syntax.cyan },
185172
["@function.macro.rust"] = { fg = C.syntax.red },
186-
["@namespace.rust"] = { fg = C.syntax.purple },
173+
["@module.rust"] = { fg = C.syntax.purple },
187174
["@punctuation.special.rust"] = { fg = C.syntax.purple },
188175
["@type.rust"] = { fg = C.syntax.cyan },
189176

@@ -200,6 +187,106 @@ local function callback(opts)
200187

201188
-- yaml
202189
["@field.yaml"] = { fg = C.syntax.red },
190+
191+
------------
192+
-- LEGACY --
193+
------------
194+
195+
["@error"] = { link = "Error" },
196+
["@string.regex"] = { link = "@string.regexp" },
197+
["@float"] = { link = "@number.float" },
198+
["@parameter"] = { link = "@variable.parameter" },
199+
["@field"] = { link = "@variable.member" },
200+
201+
["@symbol"] = { link = "@string.special.symbol" },
202+
["@namespace"] = { link = "@module" },
203+
["@namespace.builtin"] = { link = "@module.builtin" },
204+
205+
["@text"] = { fg = C.syntax.text },
206+
["@text.strong"] = { link = "@markup.strong" },
207+
["@text.emphasis"] = { link = "@markup.emphasis" },
208+
["@text.strike"] = { link = "@markup.strikethrough" },
209+
["@text.underline"] = { link = "@markup.underline" },
210+
211+
["@text.title"] = { link = "@markup.heading" },
212+
["@text.title.1.markdown"] = { link = "@markup.heading.1.markdown" },
213+
["@text.title.2.markdown"] = { link = "@markup.heading.2.markdown" },
214+
["@text.title.3.markdown"] = { link = "@markup.heading.3.markdown" },
215+
["@text.title.4.markdown"] = { link = "@markup.heading.4.markdown" },
216+
["@text.title.5.markdown"] = { link = "@markup.heading.5.markdown" },
217+
218+
["@text.quote"] = { link = "@markup.quote" },
219+
["@text.math"] = { link = "@markup.math" },
220+
["@text.environment"] = { link = "@markup.environment" },
221+
["@text.environment.name"] = { link = "@markup.environment" },
222+
223+
["@text.literal"] = { link = "@markup.raw" },
224+
["@text.uri"] = { link = "@markup.link.url" },
225+
["@text.reference"] = { link = "@markup.link" },
226+
227+
["@text.todo"] = { link = "@comment.todo" },
228+
["@text.note"] = { link = "@comment.hint" },
229+
["@text.todo.note"] = { link = "@text.note" },
230+
["@text.warning"] = { link = "@comment.warning" },
231+
["@text.todo.warning"] = { link = "@text.warning" },
232+
["@text.danger"] = { link = "@comment.error" },
233+
["@text.todo.danger"] = { link = "@text.danger" },
234+
["@text.unchecked"] = { link = "@markup.list.unchecked" },
235+
["@text.todo.unchecked"] = { link = "@text.unchecked" },
236+
["@text.checked"] = { link = "@markup.list.checked" },
237+
["@text.todo.checked"] = { link = "@text.checked" },
238+
239+
["@text.diff.add"] = { link = "@diff.plus" },
240+
["@text.diff.delete"] = { link = "@diff.minus" },
241+
242+
["@method"] = { link = "@function" },
243+
["@method.call"] = { link = "@function.method" },
244+
245+
["@keyword.export"] = { link = "@keyword" },
246+
["@storageclass"] = { link = "@keyword.storageclass" },
247+
["@conditional"] = { link = "@keyword.conditional" },
248+
["@conditional.ternary"] = { link = "@keyword.conditional.ternary" },
249+
250+
["@repeat"] = { link = "@keyword.repeat" },
251+
["@debug"] = { link = "@keyword.debug" },
252+
["@include"] = { link = "@keyword.include" },
253+
["@exception"] = { link = "@keyword.exception" },
254+
255+
["@preproc"] = { link = "@keyword.directive" },
256+
["@define"] = { link = "@keyword.directive.define" },
257+
258+
-- semantic tokens
259+
["@annotation"] = { fg = C.syntax.yellow },
260+
["@class"] = { fg = C.syntax.blue },
261+
["@decorator"] = { fg = C.syntax.orange },
262+
["@enum"] = { fg = C.syntax.cyan },
263+
["@enumMember"] = { fg = C.syntax.orange },
264+
["@event"] = { fg = C.syntax.orange },
265+
["@interface"] = { fg = C.syntax.orange },
266+
["@modifier"] = { fg = C.syntax.orange },
267+
["@regexp"] = { fg = C.syntax.cyan },
268+
["@struct"] = { fg = C.syntax.blue },
269+
["@typeParameter"] = { fg = C.syntax.yellow },
270+
271+
-----------------------
272+
-- Language Specific --
273+
-----------------------
274+
-- markdown
275+
["@literal.markdown"] = { fg = C.syntax.green },
276+
["@none.markdown"] = { fg = C.syntax.text },
277+
["@punctuation.delimiter.markdown"] = { link = "@punctuation.delimiter" },
278+
["@punctuation.special.markdown"] = { link = "@punctuation.special" },
279+
["@title.markdown"] = { link = "markup.heading" },
280+
281+
-- PHP
282+
["@method.php"] = { link = "@function.method.php" },
283+
["@method.call.php"] = { link = "@function.method.call.php" },
284+
285+
-- Ruby
286+
["@symbol.ruby"] = { link = "@string.special.symbol.ruby" },
287+
288+
-- rust
289+
["@namespace.rust"] = { link = "@module.rust" },
203290
}
204291
-- https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md
205292
end

0 commit comments

Comments
 (0)