Skip to content

Commit 5d097df

Browse files
committed
Linking highlights groups for better maintanability
1 parent 7bf26b5 commit 5d097df

1 file changed

Lines changed: 62 additions & 67 deletions

File tree

colors/codedark.vim

Lines changed: 62 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ fun! <sid>hi(group, fg, bg, attr, sp)
3232
endfun
3333
" Choose old or new name for Treesitter groups depending on Neovim version
3434
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)
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
37+
38+
fun! <sid>hiTSlink(g_new, g_old, link)
39+
exec "hi! link " . (has("nvim-0.8.0") ? a:g_new : a:g_old) . " " . a:link
3640
endfun
3741

3842
" ------------------
@@ -144,13 +148,13 @@ let s:cdPink = {'gui': '#C586C0', 'cterm': s:cterm0E, 'cterm256': '176'}
144148
if g:codedark_conservative | let s:cdPink = s:cdBlue | endif
145149
let s:cdSilver = {'gui': '#C0C0C0', 'cterm': s:cterm05, 'cterm256': '7'}
146150

147-
" Vim editor colors
151+
" UI (built-in)
148152
" <sid>hi(GROUP, FOREGROUND, BACKGROUND, ATTRIBUTE, SPECIAL)
149153
call <sid>hi('Normal', s:cdFront, s:cdBack, 'none', {})
150154
call <sid>hi('ColorColumn', {}, s:cdCursorDarkDark, 'none', {})
151155
call <sid>hi('Cursor', s:cdCursorDark, s:cdCursorLight, 'none', {})
152156
call <sid>hi('CursorLine', {}, s:cdCursorDarkDark, 'none', {})
153-
call <sid>hi('CursorColumn', {}, s:cdCursorDarkDark, 'none', {})
157+
hi! link CursorColumn CursorLine
154158
call <sid>hi('Directory', s:cdBlue, s:cdNone, 'none', {})
155159
call <sid>hi('DiffAdd', s:cdFront, s:cdDiffGreenLight, 'none', {})
156160
call <sid>hi('DiffChange', s:cdFront, s:cdDiffBlue, 'none', {})
@@ -167,7 +171,7 @@ call <sid>hi('LineNr', s:cdLineNumber, s:cdBack, 'none', {})
167171
call <sid>hi('CursorLineNr', s:cdPopupFront, s:cdBack, 'none', {})
168172
call <sid>hi('MatchParen', s:cdNone, s:cdCursorDark, 'none', {})
169173
call <sid>hi('ModeMsg', s:cdFront, s:cdLeftDark, 'none', {})
170-
call <sid>hi('MoreMsg', s:cdFront, s:cdLeftDark, 'none', {})
174+
hi! link MoreMsg ModeMsg
171175
call <sid>hi('NonText', s:cdLineNumber, s:cdNone, 'none', {})
172176
call <sid>hi('Pmenu', s:cdPopupFront, s:cdPopupBack, 'none', {})
173177
call <sid>hi('PmenuSel', s:cdPopupFront, s:cdPopupHighlightBlue, 'none', {})
@@ -183,7 +187,7 @@ call <sid>hi('TabLineFill', s:cdFront, s:cdTabOutside, 'none', {})
183187
call <sid>hi('TabLineSel', s:cdFront, s:cdTabCurrent, 'none', {})
184188
call <sid>hi('Title', s:cdNone, s:cdNone, 'bold', {})
185189
call <sid>hi('Visual', s:cdNone, s:cdSelection, 'none', {})
186-
call <sid>hi('VisualNOS', s:cdNone, s:cdSelection, 'none', {})
190+
hi! link VisualNOS Visual
187191
call <sid>hi('WarningMsg', s:cdOrange, s:cdBack, 'none', {})
188192
call <sid>hi('WildMenu', s:cdNone, s:cdSelection, 'none', {})
189193
call <sid>hi('netrwMarkFile', s:cdFront, s:cdSelection, 'none', {})
@@ -195,119 +199,111 @@ hi! link diffRemoved DiffDelete
195199

196200
if g:codedark_italics | call <sid>hi('Comment', s:cdGreen, {}, 'italic', {}) | else | call <sid>hi('Comment', s:cdGreen, {}, 'none', {}) | endif
197201

202+
" SYNTAX HIGHLIGHT (built-in)
198203
call <sid>hi('Constant', s:cdBlue, {}, 'none', {})
199204
call <sid>hi('String', s:cdOrange, {}, 'none', {})
200205
call <sid>hi('Character', s:cdOrange, {}, 'none', {})
201206
call <sid>hi('Number', s:cdLightGreen, {}, 'none', {})
202207
call <sid>hi('Boolean', s:cdBlue, {}, 'none', {})
203-
call <sid>hi('Float', s:cdLightGreen, {}, 'none', {})
204-
208+
hi! link Float Number
205209
call <sid>hi('Identifier', s:cdLightBlue, {}, 'none', {})
206210
call <sid>hi('Function', s:cdYellow, {}, 'none', {})
207-
208211
call <sid>hi('Statement', s:cdPink, {}, 'none', {})
209212
call <sid>hi('Conditional', s:cdPink, {}, 'none', {})
210213
call <sid>hi('Repeat', s:cdPink, {}, 'none', {})
211214
call <sid>hi('Label', s:cdPink, {}, 'none', {})
212215
call <sid>hi('Operator', s:cdFront, {}, 'none', {})
213216
call <sid>hi('Keyword', s:cdPink, {}, 'none', {})
214217
call <sid>hi('Exception', s:cdPink, {}, 'none', {})
215-
216218
call <sid>hi('PreProc', s:cdPink, {}, 'none', {})
217219
call <sid>hi('Include', s:cdPink, {}, 'none', {})
218220
call <sid>hi('Define', s:cdPink, {}, 'none', {})
219221
call <sid>hi('Macro', s:cdPink, {}, 'none', {})
220222
call <sid>hi('PreCondit', s:cdPink, {}, 'none', {})
221-
222223
call <sid>hi('Type', s:cdBlue, {}, 'none', {})
223224
call <sid>hi('StorageClass', s:cdBlue, {}, 'none', {})
224225
call <sid>hi('Structure', s:cdBlue, {}, 'none', {})
225226
call <sid>hi('Typedef', s:cdBlue, {}, 'none', {})
226-
227227
call <sid>hi('Special', s:cdYellowOrange, {}, 'none', {})
228228
call <sid>hi('SpecialChar', s:cdFront, {}, 'none', {})
229229
call <sid>hi('Tag', s:cdFront, {}, 'none', {})
230230
call <sid>hi('Delimiter', s:cdFront, {}, 'none', {})
231231
if g:codedark_italics | call <sid>hi('SpecialComment', s:cdGreen, {}, 'italic', {}) | else | call <sid>hi('SpecialComment', s:cdGreen, {}, 'none', {}) | endif
232232
call <sid>hi('Debug', s:cdFront, {}, 'none', {})
233-
234233
call <sid>hi('Underlined', s:cdNone, {}, 'underline', {})
235234
call <sid>hi("Conceal", s:cdFront, s:cdBack, 'none', {})
236-
237235
call <sid>hi('Ignore', s:cdBack, {}, 'none', {})
238-
239236
call <sid>hi('Error', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
240-
241237
call <sid>hi('Todo', s:cdNone, s:cdLeftMid, 'none', {})
242-
243238
call <sid>hi('SpellBad', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
244239
call <sid>hi('SpellCap', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
245240
call <sid>hi('SpellRare', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
246241
call <sid>hi('SpellLocal', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
247242

243+
" NEOVIM
248244
" Make neovim specific groups load only on Neovim
249245
if has("nvim")
250-
" Neovim Treesitter:
251-
call <sid>hiTS('@error', 'TSError', s:cdRed, {}, 'none', {})
252-
call <sid>hiTS('@punctuation.delimiter', 'TSPunctDelimiter', s:cdFront, {}, 'none', {})
253-
call <sid>hiTS('@punctuation.bracket', 'TSPunctBracket', s:cdFront, {}, 'none', {})
254-
call <sid>hiTS('@punctuation.special', 'TSPunctSpecial', s:cdFront, {}, 'none', {})
246+
" nvim-treesitter/nvim-treesitter (github)
247+
call <sid>hiTSlink('@error', 'TSError', 'ErrorMsg')
248+
call <sid>hiTSlink('@punctuation.delimiter', 'TSPunctDelimiter', 'Delimiter')
249+
call <sid>hiTSlink('@punctuation.bracket', 'TSPunctBracket', 'Delimiter')
250+
call <sid>hiTSlink('@punctuation.special', 'TSPunctSpecial', 'Delimiter')
255251
" Constant
256252
call <sid>hiTS('@constant', 'TSConstant', s:cdYellow, {}, 'none', {})
257-
call <sid>hiTS('@constant.builtin', 'TSConstBuiltin', s:cdBlue, {}, 'none', {})
253+
call <sid>hiTSlink('@constant.builtin', 'TSConstBuiltin', 'Constant')
258254
call <sid>hiTS('@constant.macro', 'TSConstMacro', s:cdBlueGreen, {}, 'none', {})
259-
call <sid>hiTS('@string.regex', 'TSStringRegex', s:cdOrange, {}, 'none', {})
260-
call <sid>hiTS('@string', 'TSString', s:cdOrange, {}, 'none', {})
255+
call <sid>hiTSlink('@string', 'TSString', 'String')
256+
call <sid>hiTSlink('@string.regex', 'TSStringRegex', 'String')
261257
call <sid>hiTS('@string.escape', 'TSStringEscape', s:cdYellowOrange, {}, 'none', {})
262-
call <sid>hiTS('@character', 'TSCharacter', s:cdOrange, {}, 'none', {})
263-
call <sid>hiTS('@number', 'TSNumber', s:cdLightGreen, {}, 'none', {})
258+
call <sid>hiTSlink('@character', 'TSCharacter', 'Character')
259+
call <sid>hiTSlink('@number', 'TSNumber', 'Number')
264260
call <sid>hiTS('@boolean', 'TSBoolean', s:cdBlue, {}, 'none', {})
265-
call <sid>hiTS('@float', 'TSFloat', s:cdLightGreen, {}, 'none', {})
261+
call <sid>hiTSlink('@float', 'TSFloat', 'Float')
266262
call <sid>hiTS('@annotation', 'TSAnnotation', s:cdYellow, {}, 'none', {})
267263
call <sid>hiTS('@attribute', 'TSAttribute', s:cdBlueGreen, {}, 'none', {})
268264
call <sid>hiTS('@namespace', 'TSNamespace', s:cdBlueGreen, {}, 'none', {})
269265
" Functions
270-
call <sid>hiTS('@function.builtin', 'TSFuncBuiltin', s:cdYellow, {}, 'none', {})
271-
call <sid>hiTS('@function', 'TSFunction', s:cdYellow, {}, 'none', {})
272-
call <sid>hiTS('@function.macro', 'TSFuncMacro', s:cdYellow, {}, 'none', {})
266+
call <sid>hiTSlink('@function.builtin', 'TSFuncBuiltin', 'Function')
267+
call <sid>hiTSlink('@function', 'TSFunction','Function')
268+
call <sid>hiTSlink('@function.macro', 'TSFuncMacro','Function')
273269
call <sid>hiTS('@parameter', 'TSParameter', s:cdLightBlue, {}, 'none', {})
274270
call <sid>hiTS('@parameter.reference', 'TSParameterReference', s:cdLightBlue, {}, 'none', {})
275271
call <sid>hiTS('@method', 'TSMethod', s:cdYellow, {}, 'none', {})
276272
call <sid>hiTS('@field', 'TSField', s:cdLightBlue, {}, 'none', {})
277273
call <sid>hiTS('@property', 'TSProperty', s:cdLightBlue, {}, 'none', {})
278274
call <sid>hiTS('@constructor', 'TSConstructor', s:cdBlueGreen, {}, 'none', {})
279275
" Keywords
280-
call <sid>hiTS('@conditional', 'TSConditional', s:cdPink, {}, 'none', {})
281-
call <sid>hiTS('@repeat', 'TSRepeat', s:cdPink, {}, 'none', {})
276+
call <sid>hiTSlink('@conditional', 'TSConditional', 'Conditional')
277+
call <sid>hiTSlink('@repeat', 'TSRepeat', 'Repeat')
282278
call <sid>hiTS('@label', 'TSLabel', s:cdLightBlue, {}, 'none', {})
283279
call <sid>hiTS('@keyword', 'TSKeyword', s:cdBlue, {}, 'none', {})
284280
call <sid>hiTS('@keyword.function', 'TSKeywordFunction', s:cdBlue, {}, 'none', {})
285281
call <sid>hiTS('@keyword.operator', 'TSKeywordOperator', s:cdBlue, {}, 'none', {})
286282
call <sid>hiTS('@operator', 'TSOperator', s:cdFront, {}, 'none', {})
287283
call <sid>hiTS('@exception', 'TSException', s:cdPink, {}, 'none', {})
288284
call <sid>hiTS('@type', 'TSType', s:cdBlueGreen, {}, 'none', {})
289-
call <sid>hiTS('@type.builtin', 'TSTypeBuiltin', s:cdBlue, {}, 'none', {})
285+
call <sid>hiTSlink('@type.builtin', 'TSTypeBuiltin', 'Type')
290286
call <sid>hi('TSStructure', s:cdLightBlue, {}, 'none', {})
291-
call <sid>hiTS('@include', 'TSInclude', s:cdPink, {}, 'none', {})
287+
call <sid>hiTSlink('@include', 'TSInclude', 'Include')
292288
" Variable
293289
call <sid>hiTS('@variable', 'TSVariable', s:cdLightBlue, {}, 'none', {})
294290
call <sid>hiTS('@variable.builtin', 'TSVariableBuiltin', s:cdLightBlue, {}, 'none', {})
295291
" Text
296-
call <sid>hiTS('@text', 'TSText', s:cdYellowOrange, {}, 'none', {})
297-
call <sid>hiTS('@text.strong', 'TSStrong', s:cdYellowOrange, {}, 'none', {})
298-
call <sid>hiTS('@text.emphasis', 'TSEmphasis', s:cdYellowOrange, {}, 'none', {})
299-
call <sid>hiTS('@text.underline', 'TSUnderline', s:cdYellowOrange, {}, 'none', {})
300-
call <sid>hiTS('@text.title', 'TSTitle', s:cdYellowOrange, {}, 'none', {})
301-
call <sid>hiTS('@text.literal', 'TSLiteral', s:cdYellowOrange, {}, 'none', {})
302-
call <sid>hiTS('@text.uri', 'TSURI', s:cdYellowOrange, {}, 'none', {})
292+
call <sid>hiTS('@text', 'TSText', s:cdFront, s:cdNone, 'bold', {})
293+
call <sid>hiTS('@text.strong', 'TSStrong', s:cdFront, s:cdNone, 'bold', {})
294+
call <sid>hiTS('@text.emphasis', 'TSEmphasis', s:cdYellowOrange, s:cdNone, 'italic', {})
295+
hi! link @text.underline Underlined
296+
call <sid>hiTS('@text.title', 'TSTitle', s:cdBlue, {}, 'bold', {})
297+
call <sid>hiTS('@text.literal', 'TSLiteral', s:cdOrange, {}, 'none', {})
298+
call <sid>hiTS('@text.uri', 'TSURI', s:cdOrange, {}, 'none', {})
303299
" Tags
304300
call <sid>hiTS('@tag', 'TSTag', s:cdBlue, {}, 'none', {})
305301
call <sid>hiTS('@tag.delimiter', 'TSTagDelimiter', s:cdGray, {}, 'none', {})
306302

307-
" nvim-cmp
303+
" hrsh7th/nvim-cmp (github)
308304
call <sid>hi('CmpItemAbbrDeprecated', s:cdGray, {}, 'none', {})
309305
call <sid>hi('CmpItemAbbrMatch', s:cdBlue, {}, 'none', {})
310-
call <sid>hi('CmpItemAbbrMatchFuzzy', s:cdBlue, {}, 'none', {})
306+
hi! link CmpItemAbbrMatchFuzzy CmpItemAbbrMatch
311307
call <sid>hi('CmpItemKindVariable', s:cdLightBlue, {}, 'none', {})
312308
call <sid>hi('CmpItemKindInterface', s:cdLightBlue, {}, 'none', {})
313309
call <sid>hi('CmpItemKindText', s:cdLightBlue, {}, 'none', {})
@@ -318,25 +314,25 @@ if has("nvim")
318314
call <sid>hi('CmpItemKindUnit', s:cdFront, {}, 'none', {})
319315
endif
320316

321-
" Markdown:
317+
" MARKDOWN (built-in)
322318
call <sid>hi('markdownH1', s:cdBlue, {}, 'bold', {})
323-
call <sid>hi('markdownH2', s:cdBlue, {}, 'bold', {})
324-
call <sid>hi('markdownH3', s:cdBlue, {}, 'bold', {})
325-
call <sid>hi('markdownH4', s:cdBlue, {}, 'bold', {})
326-
call <sid>hi('markdownH5', s:cdBlue, {}, 'bold', {})
327-
call <sid>hi('markdownH6', s:cdBlue, {}, 'bold', {})
319+
hi! link markdownH2 markdownH1
320+
hi! link markdownH3 markdownH1
321+
hi! link markdownH4 markdownH1
322+
hi! link markdownH5 markdownH1
323+
hi! link markdownH6 markdownH1
324+
call <sid>hi('markdownHeadingDelimiter', s:cdBlue, {}, 'none', {})
328325
call <sid>hi('markdownBold', s:cdBlue, {}, 'bold', {})
329-
call <sid>hi('markdownCode', s:cdOrange, {}, 'none', {})
330326
call <sid>hi('markdownRule', s:cdBlue, {}, 'bold', {})
331-
call <sid>hi('markdownCodeDelimiter', s:cdOrange, {}, 'none', {})
332-
call <sid>hi('markdownHeadingDelimiter', s:cdBlue, {}, 'none', {})
327+
call <sid>hi('markdownCode', s:cdOrange, {}, 'none', {})
328+
hi! link markdownCodeDelimiter markdownCode
333329
call <sid>hi('markdownFootnote', s:cdOrange, {}, 'none', {})
334-
call <sid>hi('markdownFootnoteDefinition', s:cdOrange, {}, 'none', {})
330+
hi! link markdownFootnoteDefinition markdownFootnote
335331
call <sid>hi('markdownUrl', s:cdLightBlue, {}, 'underline', {})
336332
call <sid>hi('markdownLinkText', s:cdOrange, {}, 'none', {})
337333
call <sid>hi('markdownEscape', s:cdYellowOrange, {}, 'none', {})
338334

339-
" Asciidoc (for default syntax highlighting)
335+
" ASCIIDOC (built-in)
340336
call <sid>hi("asciidocAttributeEntry", s:cdYellowOrange, {}, 'none', {})
341337
call <sid>hi("asciidocAttributeList", s:cdPink, {}, 'none', {})
342338
call <sid>hi("asciidocAttributeRef", s:cdYellowOrange, {}, 'none', {})
@@ -359,30 +355,30 @@ hi! link asciidocQuotedUnconstrainedBold asciidocQuotedBold
359355
hi! link asciidocQuotedUnconstrainedEmphasized asciidocQuotedEmphasized
360356
hi! link asciidocURL markdownUrl
361357

362-
" JSON:
358+
" JSON (built-in)
363359
call <sid>hi('jsonKeyword', s:cdLightBlue, {}, 'none', {})
364360
call <sid>hi('jsonEscape', s:cdYellowOrange, {}, 'none', {})
365361
call <sid>hi('jsonNull', s:cdBlue, {}, 'none', {})
366362
call <sid>hi('jsonBoolean', s:cdBlue, {}, 'none', {})
367363

368-
" HTML:
364+
" HTML (built-in)
369365
call <sid>hi('htmlTag', s:cdGray, {}, 'none', {})
370366
call <sid>hi('htmlEndTag', s:cdGray, {}, 'none', {})
371367
call <sid>hi('htmlTagName', s:cdBlue, {}, 'none', {})
372-
call <sid>hi('htmlSpecialTagName', s:cdBlue, {}, 'none', {})
368+
hi! link htmlSpecialTagName htmlTagName
373369
call <sid>hi('htmlArg', s:cdLightBlue, {}, 'none', {})
374370

375-
" PHP:
376-
call <sid>hi('phpStaticClasses', s:cdBlueGreen, {}, 'none', {})
377-
call <sid>hi('phpMethod', s:cdYellow, {}, 'none', {})
371+
" PHP (built-in)
378372
call <sid>hi('phpClass', s:cdBlueGreen, {}, 'none', {})
373+
hi! link phpUseClass phpClass
374+
hi! link phpStaticClasses phpClass
375+
call <sid>hi('phpMethod', s:cdYellow, {}, 'none', {})
379376
call <sid>hi('phpFunction', s:cdYellow, {}, 'none', {})
380377
call <sid>hi('phpInclude', s:cdBlue, {}, 'none', {})
381-
call <sid>hi('phpUseClass', s:cdBlueGreen, {}, 'none', {})
382378
call <sid>hi('phpRegion', s:cdBlueGreen, {}, 'none', {})
383379
call <sid>hi('phpMethodsVar', s:cdLightBlue, {}, 'none', {})
384380

385-
" CSS:
381+
" CSS (built-in)
386382
call <sid>hi('cssBraces', s:cdFront, {}, 'none', {})
387383
call <sid>hi('cssInclude', s:cdPink, {}, 'none', {})
388384
call <sid>hi('cssTagName', s:cdBlue, {}, 'none', {})
@@ -568,16 +564,16 @@ call <sid>hi('texBeginEndModifier', s:cdLightBlue, {}, 'none', {})
568564
call <sid>hi('texDocType', s:cdPink, {}, 'none', {})
569565
call <sid>hi('texDocTypeArgs', s:cdLightBlue, {}, 'none', {})
570566

571-
" Git:
567+
" GIT (built-in)
572568
call <sid>hi('gitcommitHeader', s:cdGray, {}, 'none', {})
573569
call <sid>hi('gitcommitOnBranch', s:cdGray, {}, 'none', {})
574570
call <sid>hi('gitcommitBranch', s:cdPink, {}, 'none', {})
575571
call <sid>hi('gitcommitComment', s:cdGray, {}, 'none', {})
576572
call <sid>hi('gitcommitSelectedType', s:cdGreen, {}, 'none', {})
577-
call <sid>hi('gitcommitSelectedFile', s:cdGreen, {}, 'none', {})
573+
hi! link gitcommitSelectedFile gitcommitSelectedType
578574
call <sid>hi('gitcommitDiscardedType', s:cdRed, {}, 'none', {})
579-
call <sid>hi('gitcommitDiscardedFile', s:cdRed, {}, 'none', {})
580-
call <sid>hi('gitcommitOverflow', s:cdRed, {}, 'none', {})
575+
hi! link gitcommitDiscardedFile gitcommitDiscardedType
576+
hi! link gitcommitOverflow gitcommitDiscardedType
581577
call <sid>hi('gitcommitSummary', s:cdPink, {}, 'none', {})
582578
call <sid>hi('gitcommitBlank', s:cdPink, {}, 'none', {})
583579

@@ -588,7 +584,6 @@ call <sid>hi('luaFuncKeyword', s:cdPink, {}, 'none', {})
588584
call <sid>hi('luaLocal', s:cdPink, {}, 'none', {})
589585
call <sid>hi('luaBuiltIn', s:cdBlue, {}, 'none', {})
590586

591-
592587
" SH:
593588
call <sid>hi('shDeref', s:cdLightBlue, {}, 'none', {})
594589
call <sid>hi('shVariable', s:cdLightBlue, {}, 'none', {})

0 commit comments

Comments
 (0)