Skip to content

Commit 48d4470

Browse files
authored
Merge pull request #109 from capybarapantsu-xe/ts-0.8-compat
Rename all Treesitter highlight groups
2 parents a40dc19 + 14b3e6a commit 48d4470

1 file changed

Lines changed: 52 additions & 48 deletions

File tree

colors/codedark.vim

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ fun! <sid>hi(group, fg, bg, attr, sp)
3030
exec "hi " . a:group . " guisp=" . a:sp.gui
3131
endif
3232
endfun
33+
" Choose old or new name for Treesitter groups depending on Neovim version
34+
fun! <sid>hiTS(g_new, g_old, fg, bg, attr, sp)
35+
call <sid>hi(has("nvim-0.8.0")? a:g_new : a:g_old, a:fg, a:bg, a:attr, a:sp)
36+
endfun
3337

3438
" ------------------
3539
" Color definitions:
@@ -243,61 +247,61 @@ call <sid>hi('SpellLocal', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
243247

244248

245249
" Neovim Treesitter:
246-
call <sid>hi('TSError', s:cdRed, {}, 'none', {})
247-
call <sid>hi('TSPunctDelimiter', s:cdFront, {}, 'none', {})
248-
call <sid>hi('TSPunctBracket', s:cdFront, {}, 'none', {})
249-
call <sid>hi('TSPunctSpecial', s:cdFront, {}, 'none', {})
250+
call <sid>hiTS('@error', 'TSError', s:cdRed, {}, 'none', {})
251+
call <sid>hiTS('@punctuation.delimiter', 'TSPunctDelimiter', s:cdFront, {}, 'none', {})
252+
call <sid>hiTS('@punctuation.bracket', 'TSPunctBracket', s:cdFront, {}, 'none', {})
253+
call <sid>hiTS('@punctuation.special', 'TSPunctSpecial', s:cdFront, {}, 'none', {})
250254
" Constant
251-
call <sid>hi('TSConstant', s:cdYellow, {}, 'none', {})
252-
call <sid>hi('TSConstBuiltin', s:cdBlue, {}, 'none', {})
253-
call <sid>hi('TSConstMacro', s:cdBlueGreen, {}, 'none', {})
254-
call <sid>hi('TSStringRegex', s:cdOrange, {}, 'none', {})
255-
call <sid>hi('TSString', s:cdOrange, {}, 'none', {})
256-
call <sid>hi('TSStringEscape', s:cdYellowOrange, {}, 'none', {})
257-
call <sid>hi('TSCharacter', s:cdOrange, {}, 'none', {})
258-
call <sid>hi('TSNumber', s:cdLightGreen, {}, 'none', {})
259-
call <sid>hi('TSBoolean', s:cdBlue, {}, 'none', {})
260-
call <sid>hi('TSFloat', s:cdLightGreen, {}, 'none', {})
261-
call <sid>hi('TSAnnotation', s:cdYellow, {}, 'none', {})
262-
call <sid>hi('TSAttribute', s:cdBlueGreen, {}, 'none', {})
263-
call <sid>hi('TSNamespace', s:cdBlueGreen, {}, 'none', {})
255+
call <sid>hiTS('@constant', 'TSConstant', s:cdYellow, {}, 'none', {})
256+
call <sid>hiTS('@constant.builtin', 'TSConstBuiltin', s:cdBlue, {}, 'none', {})
257+
call <sid>hiTS('@constant.macro', 'TSConstMacro', s:cdBlueGreen, {}, 'none', {})
258+
call <sid>hiTS('@string.regex', 'TSStringRegex', s:cdOrange, {}, 'none', {})
259+
call <sid>hiTS('@string', 'TSString', s:cdOrange, {}, 'none', {})
260+
call <sid>hiTS('@string.escape', 'TSStringEscape', s:cdYellowOrange, {}, 'none', {})
261+
call <sid>hiTS('@character', 'TSCharacter', s:cdOrange, {}, 'none', {})
262+
call <sid>hiTS('@number', 'TSNumber', s:cdLightGreen, {}, 'none', {})
263+
call <sid>hiTS('@boolean', 'TSBoolean', s:cdBlue, {}, 'none', {})
264+
call <sid>hiTS('@float', 'TSFloat', s:cdLightGreen, {}, 'none', {})
265+
call <sid>hiTS('@annotation', 'TSAnnotation', s:cdYellow, {}, 'none', {})
266+
call <sid>hiTS('@attribute', 'TSAttribute', s:cdBlueGreen, {}, 'none', {})
267+
call <sid>hiTS('@namespace', 'TSNamespace', s:cdBlueGreen, {}, 'none', {})
264268
" Functions
265-
call <sid>hi('TSFuncBuiltin', s:cdYellow, {}, 'none', {})
266-
call <sid>hi('TSFunction', s:cdYellow, {}, 'none', {})
267-
call <sid>hi('TSFuncMacro', s:cdYellow, {}, 'none', {})
268-
call <sid>hi('TSParameter', s:cdLightBlue, {}, 'none', {})
269-
call <sid>hi('TSParameterReference', s:cdLightBlue, {}, 'none', {})
270-
call <sid>hi('TSMethod', s:cdYellow, {}, 'none', {})
271-
call <sid>hi('TSField', s:cdLightBlue, {}, 'none', {})
272-
call <sid>hi('TSProperty', s:cdLightBlue, {}, 'none', {})
273-
call <sid>hi('TSConstructor', s:cdBlueGreen, {}, 'none', {})
269+
call <sid>hiTS('@function.builtin', 'TSFuncBuiltin', s:cdYellow, {}, 'none', {})
270+
call <sid>hiTS('@function', 'TSFunction', s:cdYellow, {}, 'none', {})
271+
call <sid>hiTS('@function.macro', 'TSFuncMacro', s:cdYellow, {}, 'none', {})
272+
call <sid>hiTS('@parameter', 'TSParameter', s:cdLightBlue, {}, 'none', {})
273+
call <sid>hiTS('@parameter.reference', 'TSParameterReference', s:cdLightBlue, {}, 'none', {})
274+
call <sid>hiTS('@method', 'TSMethod', s:cdYellow, {}, 'none', {})
275+
call <sid>hiTS('@field', 'TSField', s:cdLightBlue, {}, 'none', {})
276+
call <sid>hiTS('@property', 'TSProperty', s:cdLightBlue, {}, 'none', {})
277+
call <sid>hiTS('@constructor', 'TSConstructor', s:cdBlueGreen, {}, 'none', {})
274278
" Keywords
275-
call <sid>hi('TSConditional', s:cdPink, {}, 'none', {})
276-
call <sid>hi('TSRepeat', s:cdPink, {}, 'none', {})
277-
call <sid>hi('TSLabel', s:cdLightBlue, {}, 'none', {})
278-
call <sid>hi('TSKeyword', s:cdBlue, {}, 'none', {})
279-
call <sid>hi('TSKeywordFunction', s:cdBlue, {}, 'none', {})
280-
call <sid>hi('TSKeywordOperator', s:cdBlue, {}, 'none', {})
281-
call <sid>hi('TSOperator', s:cdFront, {}, 'none', {})
282-
call <sid>hi('TSException', s:cdPink, {}, 'none', {})
283-
call <sid>hi('TSType', s:cdBlueGreen, {}, 'none', {})
284-
call <sid>hi('TSTypeBuiltin', s:cdBlue, {}, 'none', {})
279+
call <sid>hiTS('@conditional', 'TSConditional', s:cdPink, {}, 'none', {})
280+
call <sid>hiTS('@repeat', 'TSRepeat', s:cdPink, {}, 'none', {})
281+
call <sid>hiTS('@label', 'TSLabel', s:cdLightBlue, {}, 'none', {})
282+
call <sid>hiTS('@keyword', 'TSKeyword', s:cdBlue, {}, 'none', {})
283+
call <sid>hiTS('@keyword.function', 'TSKeywordFunction', s:cdBlue, {}, 'none', {})
284+
call <sid>hiTS('@keyword.operator', 'TSKeywordOperator', s:cdBlue, {}, 'none', {})
285+
call <sid>hiTS('@operator', 'TSOperator', s:cdFront, {}, 'none', {})
286+
call <sid>hiTS('@exception', 'TSException', s:cdPink, {}, 'none', {})
287+
call <sid>hiTS('@type', 'TSType', s:cdBlueGreen, {}, 'none', {})
288+
call <sid>hiTS('@type.builtin', 'TSTypeBuiltin', s:cdBlue, {}, 'none', {})
285289
call <sid>hi('TSStructure', s:cdLightBlue, {}, 'none', {})
286-
call <sid>hi('TSInclude', s:cdPink, {}, 'none', {})
290+
call <sid>hiTS('@include', 'TSInclude', s:cdPink, {}, 'none', {})
287291
" Variable
288-
call <sid>hi('TSVariable', s:cdLightBlue, {}, 'none', {})
289-
call <sid>hi('TSVariableBuiltin', s:cdLightBlue, {}, 'none', {})
292+
call <sid>hiTS('@variable', 'TSVariable', s:cdLightBlue, {}, 'none', {})
293+
call <sid>hiTS('@variable.builtin', 'TSVariableBuiltin', s:cdLightBlue, {}, 'none', {})
290294
" Text
291-
call <sid>hi('TSText', s:cdYellowOrange, {}, 'none', {})
292-
call <sid>hi('TSStrong', s:cdYellowOrange, {}, 'none', {})
293-
call <sid>hi('TSEmphasis', s:cdYellowOrange, {}, 'none', {})
294-
call <sid>hi('TSUnderline', s:cdYellowOrange, {}, 'none', {})
295-
call <sid>hi('TSTitle', s:cdYellowOrange, {}, 'none', {})
296-
call <sid>hi('TSLiteral', s:cdYellowOrange, {}, 'none', {})
297-
call <sid>hi('TSURI', s:cdYellowOrange, {}, 'none', {})
295+
call <sid>hiTS('@text', 'TSText', s:cdYellowOrange, {}, 'none', {})
296+
call <sid>hiTS('@text.strong', 'TSStrong', s:cdYellowOrange, {}, 'none', {})
297+
call <sid>hiTS('@text.emphasis', 'TSEmphasis', s:cdYellowOrange, {}, 'none', {})
298+
call <sid>hiTS('@text.underline', 'TSUnderline', s:cdYellowOrange, {}, 'none', {})
299+
call <sid>hiTS('@text.title', 'TSTitle', s:cdYellowOrange, {}, 'none', {})
300+
call <sid>hiTS('@text.literal', 'TSLiteral', s:cdYellowOrange, {}, 'none', {})
301+
call <sid>hiTS('@text.uri', 'TSURI', s:cdYellowOrange, {}, 'none', {})
298302
" Tags
299-
call <sid>hi('TSTag', s:cdBlue, {}, 'none', {})
300-
call <sid>hi('TSTagDelimiter', s:cdGray, {}, 'none', {})
303+
call <sid>hiTS('@tag', 'TSTag', s:cdBlue, {}, 'none', {})
304+
call <sid>hiTS('@tag.delimiter', 'TSTagDelimiter', s:cdGray, {}, 'none', {})
301305

302306
" Markdown:
303307
call <sid>hi('markdownH1', s:cdBlue, {}, 'bold', {})

0 commit comments

Comments
 (0)