Skip to content

Commit a97aeb0

Browse files
authored
Merge pull request #115 from saccarosium/master
Linking highlights groups for better maintanability
2 parents 5c2c2d6 + 5d097df commit a97aeb0

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
" ------------------
@@ -157,13 +161,13 @@ let s:cdPink = {'gui': '#C586C0', 'cterm': s:cterm0E, 'cterm256': '176'}
157161
if g:codedark_conservative | let s:cdPink = s:cdBlue | endif
158162
let s:cdSilver = {'gui': '#C0C0C0', 'cterm': s:cterm05, 'cterm256': '7'}
159163

160-
" Vim editor colors
164+
" UI (built-in)
161165
" <sid>hi(GROUP, FOREGROUND, BACKGROUND, ATTRIBUTE, SPECIAL)
162166
call <sid>hi('Normal', s:cdFront, s:cdBack, 'none', {})
163167
call <sid>hi('ColorColumn', {}, s:cdCursorDarkDark, 'none', {})
164168
call <sid>hi('Cursor', s:cdCursorDark, s:cdCursorLight, 'none', {})
165169
call <sid>hi('CursorLine', {}, s:cdCursorDarkDark, 'none', {})
166-
call <sid>hi('CursorColumn', {}, s:cdCursorDarkDark, 'none', {})
170+
hi! link CursorColumn CursorLine
167171
call <sid>hi('Directory', s:cdBlue, s:cdNone, 'none', {})
168172
call <sid>hi('DiffAdd', s:cdFront, s:cdDiffGreenLight, 'none', {})
169173
call <sid>hi('DiffChange', s:cdFront, s:cdDiffBlue, 'none', {})
@@ -180,7 +184,7 @@ call <sid>hi('LineNr', s:cdLineNumber, s:cdBack, 'none', {})
180184
call <sid>hi('CursorLineNr', s:cdPopupFront, s:cdBack, 'none', {})
181185
call <sid>hi('MatchParen', s:cdNone, s:cdCursorDark, 'none', {})
182186
call <sid>hi('ModeMsg', s:cdFront, s:cdLeftDark, 'none', {})
183-
call <sid>hi('MoreMsg', s:cdFront, s:cdLeftDark, 'none', {})
187+
hi! link MoreMsg ModeMsg
184188
call <sid>hi('NonText', s:cdLineNumber, s:cdNone, 'none', {})
185189
call <sid>hi('Pmenu', s:cdPopupFront, s:cdPopupBack, 'none', {})
186190
call <sid>hi('PmenuSel', s:cdPopupFront, s:cdPopupHighlightBlue, 'none', {})
@@ -196,7 +200,7 @@ call <sid>hi('TabLineFill', s:cdFront, s:cdTabOutside, 'none', {})
196200
call <sid>hi('TabLineSel', s:cdFront, s:cdTabCurrent, 'none', {})
197201
call <sid>hi('Title', s:cdNone, s:cdNone, 'bold', {})
198202
call <sid>hi('Visual', s:cdNone, s:cdSelection, 'none', {})
199-
call <sid>hi('VisualNOS', s:cdNone, s:cdSelection, 'none', {})
203+
hi! link VisualNOS Visual
200204
call <sid>hi('WarningMsg', s:cdOrange, s:cdBack, 'none', {})
201205
call <sid>hi('WildMenu', s:cdNone, s:cdSelection, 'none', {})
202206
call <sid>hi('netrwMarkFile', s:cdFront, s:cdSelection, 'none', {})
@@ -208,119 +212,111 @@ hi! link diffRemoved DiffDelete
208212

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

215+
" SYNTAX HIGHLIGHT (built-in)
211216
call <sid>hi('Constant', s:cdBlue, {}, 'none', {})
212217
call <sid>hi('String', s:cdOrange, {}, 'none', {})
213218
call <sid>hi('Character', s:cdOrange, {}, 'none', {})
214219
call <sid>hi('Number', s:cdLightGreen, {}, 'none', {})
215220
call <sid>hi('Boolean', s:cdBlue, {}, 'none', {})
216-
call <sid>hi('Float', s:cdLightGreen, {}, 'none', {})
217-
221+
hi! link Float Number
218222
call <sid>hi('Identifier', s:cdLightBlue, {}, 'none', {})
219223
call <sid>hi('Function', s:cdYellow, {}, 'none', {})
220-
221224
call <sid>hi('Statement', s:cdPink, {}, 'none', {})
222225
call <sid>hi('Conditional', s:cdPink, {}, 'none', {})
223226
call <sid>hi('Repeat', s:cdPink, {}, 'none', {})
224227
call <sid>hi('Label', s:cdPink, {}, 'none', {})
225228
call <sid>hi('Operator', s:cdFront, {}, 'none', {})
226229
call <sid>hi('Keyword', s:cdPink, {}, 'none', {})
227230
call <sid>hi('Exception', s:cdPink, {}, 'none', {})
228-
229231
call <sid>hi('PreProc', s:cdPink, {}, 'none', {})
230232
call <sid>hi('Include', s:cdPink, {}, 'none', {})
231233
call <sid>hi('Define', s:cdPink, {}, 'none', {})
232234
call <sid>hi('Macro', s:cdPink, {}, 'none', {})
233235
call <sid>hi('PreCondit', s:cdPink, {}, 'none', {})
234-
235236
call <sid>hi('Type', s:cdBlue, {}, 'none', {})
236237
call <sid>hi('StorageClass', s:cdBlue, {}, 'none', {})
237238
call <sid>hi('Structure', s:cdBlue, {}, 'none', {})
238239
call <sid>hi('Typedef', s:cdBlue, {}, 'none', {})
239-
240240
call <sid>hi('Special', s:cdYellowOrange, {}, 'none', {})
241241
call <sid>hi('SpecialChar', s:cdFront, {}, 'none', {})
242242
call <sid>hi('Tag', s:cdFront, {}, 'none', {})
243243
call <sid>hi('Delimiter', s:cdFront, {}, 'none', {})
244244
if g:codedark_italics | call <sid>hi('SpecialComment', s:cdGreen, {}, 'italic', {}) | else | call <sid>hi('SpecialComment', s:cdGreen, {}, 'none', {}) | endif
245245
call <sid>hi('Debug', s:cdFront, {}, 'none', {})
246-
247246
call <sid>hi('Underlined', s:cdNone, {}, 'underline', {})
248247
call <sid>hi("Conceal", s:cdFront, s:cdBack, 'none', {})
249-
250248
call <sid>hi('Ignore', s:cdBack, {}, 'none', {})
251-
252249
call <sid>hi('Error', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
253-
254250
call <sid>hi('Todo', s:cdNone, s:cdLeftMid, 'none', {})
255-
256251
call <sid>hi('SpellBad', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
257252
call <sid>hi('SpellCap', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
258253
call <sid>hi('SpellRare', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
259254
call <sid>hi('SpellLocal', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
260255

256+
" NEOVIM
261257
" Make neovim specific groups load only on Neovim
262258
if has("nvim")
263-
" Neovim Treesitter:
264-
call <sid>hiTS('@error', 'TSError', s:cdRed, {}, 'none', {})
265-
call <sid>hiTS('@punctuation.delimiter', 'TSPunctDelimiter', s:cdFront, {}, 'none', {})
266-
call <sid>hiTS('@punctuation.bracket', 'TSPunctBracket', s:cdFront, {}, 'none', {})
267-
call <sid>hiTS('@punctuation.special', 'TSPunctSpecial', s:cdFront, {}, 'none', {})
259+
" nvim-treesitter/nvim-treesitter (github)
260+
call <sid>hiTSlink('@error', 'TSError', 'ErrorMsg')
261+
call <sid>hiTSlink('@punctuation.delimiter', 'TSPunctDelimiter', 'Delimiter')
262+
call <sid>hiTSlink('@punctuation.bracket', 'TSPunctBracket', 'Delimiter')
263+
call <sid>hiTSlink('@punctuation.special', 'TSPunctSpecial', 'Delimiter')
268264
" Constant
269265
call <sid>hiTS('@constant', 'TSConstant', s:cdYellow, {}, 'none', {})
270-
call <sid>hiTS('@constant.builtin', 'TSConstBuiltin', s:cdBlue, {}, 'none', {})
266+
call <sid>hiTSlink('@constant.builtin', 'TSConstBuiltin', 'Constant')
271267
call <sid>hiTS('@constant.macro', 'TSConstMacro', s:cdBlueGreen, {}, 'none', {})
272-
call <sid>hiTS('@string.regex', 'TSStringRegex', s:cdOrange, {}, 'none', {})
273-
call <sid>hiTS('@string', 'TSString', s:cdOrange, {}, 'none', {})
268+
call <sid>hiTSlink('@string', 'TSString', 'String')
269+
call <sid>hiTSlink('@string.regex', 'TSStringRegex', 'String')
274270
call <sid>hiTS('@string.escape', 'TSStringEscape', s:cdYellowOrange, {}, 'none', {})
275-
call <sid>hiTS('@character', 'TSCharacter', s:cdOrange, {}, 'none', {})
276-
call <sid>hiTS('@number', 'TSNumber', s:cdLightGreen, {}, 'none', {})
271+
call <sid>hiTSlink('@character', 'TSCharacter', 'Character')
272+
call <sid>hiTSlink('@number', 'TSNumber', 'Number')
277273
call <sid>hiTS('@boolean', 'TSBoolean', s:cdBlue, {}, 'none', {})
278-
call <sid>hiTS('@float', 'TSFloat', s:cdLightGreen, {}, 'none', {})
274+
call <sid>hiTSlink('@float', 'TSFloat', 'Float')
279275
call <sid>hiTS('@annotation', 'TSAnnotation', s:cdYellow, {}, 'none', {})
280276
call <sid>hiTS('@attribute', 'TSAttribute', s:cdBlueGreen, {}, 'none', {})
281277
call <sid>hiTS('@namespace', 'TSNamespace', s:cdBlueGreen, {}, 'none', {})
282278
" Functions
283-
call <sid>hiTS('@function.builtin', 'TSFuncBuiltin', s:cdYellow, {}, 'none', {})
284-
call <sid>hiTS('@function', 'TSFunction', s:cdYellow, {}, 'none', {})
285-
call <sid>hiTS('@function.macro', 'TSFuncMacro', s:cdYellow, {}, 'none', {})
279+
call <sid>hiTSlink('@function.builtin', 'TSFuncBuiltin', 'Function')
280+
call <sid>hiTSlink('@function', 'TSFunction','Function')
281+
call <sid>hiTSlink('@function.macro', 'TSFuncMacro','Function')
286282
call <sid>hiTS('@parameter', 'TSParameter', s:cdLightBlue, {}, 'none', {})
287283
call <sid>hiTS('@parameter.reference', 'TSParameterReference', s:cdLightBlue, {}, 'none', {})
288284
call <sid>hiTS('@method', 'TSMethod', s:cdYellow, {}, 'none', {})
289285
call <sid>hiTS('@field', 'TSField', s:cdLightBlue, {}, 'none', {})
290286
call <sid>hiTS('@property', 'TSProperty', s:cdLightBlue, {}, 'none', {})
291287
call <sid>hiTS('@constructor', 'TSConstructor', s:cdBlueGreen, {}, 'none', {})
292288
" Keywords
293-
call <sid>hiTS('@conditional', 'TSConditional', s:cdPink, {}, 'none', {})
294-
call <sid>hiTS('@repeat', 'TSRepeat', s:cdPink, {}, 'none', {})
289+
call <sid>hiTSlink('@conditional', 'TSConditional', 'Conditional')
290+
call <sid>hiTSlink('@repeat', 'TSRepeat', 'Repeat')
295291
call <sid>hiTS('@label', 'TSLabel', s:cdLightBlue, {}, 'none', {})
296292
call <sid>hiTS('@keyword', 'TSKeyword', s:cdBlue, {}, 'none', {})
297293
call <sid>hiTS('@keyword.function', 'TSKeywordFunction', s:cdBlue, {}, 'none', {})
298294
call <sid>hiTS('@keyword.operator', 'TSKeywordOperator', s:cdBlue, {}, 'none', {})
299295
call <sid>hiTS('@operator', 'TSOperator', s:cdFront, {}, 'none', {})
300296
call <sid>hiTS('@exception', 'TSException', s:cdPink, {}, 'none', {})
301297
call <sid>hiTS('@type', 'TSType', s:cdBlueGreen, {}, 'none', {})
302-
call <sid>hiTS('@type.builtin', 'TSTypeBuiltin', s:cdBlue, {}, 'none', {})
298+
call <sid>hiTSlink('@type.builtin', 'TSTypeBuiltin', 'Type')
303299
call <sid>hi('TSStructure', s:cdLightBlue, {}, 'none', {})
304-
call <sid>hiTS('@include', 'TSInclude', s:cdPink, {}, 'none', {})
300+
call <sid>hiTSlink('@include', 'TSInclude', 'Include')
305301
" Variable
306302
call <sid>hiTS('@variable', 'TSVariable', s:cdLightBlue, {}, 'none', {})
307303
call <sid>hiTS('@variable.builtin', 'TSVariableBuiltin', s:cdLightBlue, {}, 'none', {})
308304
" Text
309-
call <sid>hiTS('@text', 'TSText', s:cdYellowOrange, {}, 'none', {})
310-
call <sid>hiTS('@text.strong', 'TSStrong', s:cdYellowOrange, {}, 'none', {})
311-
call <sid>hiTS('@text.emphasis', 'TSEmphasis', s:cdYellowOrange, {}, 'none', {})
312-
call <sid>hiTS('@text.underline', 'TSUnderline', s:cdYellowOrange, {}, 'none', {})
313-
call <sid>hiTS('@text.title', 'TSTitle', s:cdYellowOrange, {}, 'none', {})
314-
call <sid>hiTS('@text.literal', 'TSLiteral', s:cdYellowOrange, {}, 'none', {})
315-
call <sid>hiTS('@text.uri', 'TSURI', s:cdYellowOrange, {}, 'none', {})
305+
call <sid>hiTS('@text', 'TSText', s:cdFront, s:cdNone, 'bold', {})
306+
call <sid>hiTS('@text.strong', 'TSStrong', s:cdFront, s:cdNone, 'bold', {})
307+
call <sid>hiTS('@text.emphasis', 'TSEmphasis', s:cdYellowOrange, s:cdNone, 'italic', {})
308+
hi! link @text.underline Underlined
309+
call <sid>hiTS('@text.title', 'TSTitle', s:cdBlue, {}, 'bold', {})
310+
call <sid>hiTS('@text.literal', 'TSLiteral', s:cdOrange, {}, 'none', {})
311+
call <sid>hiTS('@text.uri', 'TSURI', s:cdOrange, {}, 'none', {})
316312
" Tags
317313
call <sid>hiTS('@tag', 'TSTag', s:cdBlue, {}, 'none', {})
318314
call <sid>hiTS('@tag.delimiter', 'TSTagDelimiter', s:cdGray, {}, 'none', {})
319315

320-
" nvim-cmp
316+
" hrsh7th/nvim-cmp (github)
321317
call <sid>hi('CmpItemAbbrDeprecated', s:cdGray, {}, 'none', {})
322318
call <sid>hi('CmpItemAbbrMatch', s:cdBlue, {}, 'none', {})
323-
call <sid>hi('CmpItemAbbrMatchFuzzy', s:cdBlue, {}, 'none', {})
319+
hi! link CmpItemAbbrMatchFuzzy CmpItemAbbrMatch
324320
call <sid>hi('CmpItemKindVariable', s:cdLightBlue, {}, 'none', {})
325321
call <sid>hi('CmpItemKindInterface', s:cdLightBlue, {}, 'none', {})
326322
call <sid>hi('CmpItemKindText', s:cdLightBlue, {}, 'none', {})
@@ -331,25 +327,25 @@ if has("nvim")
331327
call <sid>hi('CmpItemKindUnit', s:cdFront, {}, 'none', {})
332328
endif
333329

334-
" Markdown:
330+
" MARKDOWN (built-in)
335331
call <sid>hi('markdownH1', s:cdBlue, {}, 'bold', {})
336-
call <sid>hi('markdownH2', s:cdBlue, {}, 'bold', {})
337-
call <sid>hi('markdownH3', s:cdBlue, {}, 'bold', {})
338-
call <sid>hi('markdownH4', s:cdBlue, {}, 'bold', {})
339-
call <sid>hi('markdownH5', s:cdBlue, {}, 'bold', {})
340-
call <sid>hi('markdownH6', s:cdBlue, {}, 'bold', {})
332+
hi! link markdownH2 markdownH1
333+
hi! link markdownH3 markdownH1
334+
hi! link markdownH4 markdownH1
335+
hi! link markdownH5 markdownH1
336+
hi! link markdownH6 markdownH1
337+
call <sid>hi('markdownHeadingDelimiter', s:cdBlue, {}, 'none', {})
341338
call <sid>hi('markdownBold', s:cdBlue, {}, 'bold', {})
342-
call <sid>hi('markdownCode', s:cdOrange, {}, 'none', {})
343339
call <sid>hi('markdownRule', s:cdBlue, {}, 'bold', {})
344-
call <sid>hi('markdownCodeDelimiter', s:cdOrange, {}, 'none', {})
345-
call <sid>hi('markdownHeadingDelimiter', s:cdBlue, {}, 'none', {})
340+
call <sid>hi('markdownCode', s:cdOrange, {}, 'none', {})
341+
hi! link markdownCodeDelimiter markdownCode
346342
call <sid>hi('markdownFootnote', s:cdOrange, {}, 'none', {})
347-
call <sid>hi('markdownFootnoteDefinition', s:cdOrange, {}, 'none', {})
343+
hi! link markdownFootnoteDefinition markdownFootnote
348344
call <sid>hi('markdownUrl', s:cdLightBlue, {}, 'underline', {})
349345
call <sid>hi('markdownLinkText', s:cdOrange, {}, 'none', {})
350346
call <sid>hi('markdownEscape', s:cdYellowOrange, {}, 'none', {})
351347

352-
" Asciidoc (for default syntax highlighting)
348+
" ASCIIDOC (built-in)
353349
call <sid>hi("asciidocAttributeEntry", s:cdYellowOrange, {}, 'none', {})
354350
call <sid>hi("asciidocAttributeList", s:cdPink, {}, 'none', {})
355351
call <sid>hi("asciidocAttributeRef", s:cdYellowOrange, {}, 'none', {})
@@ -372,30 +368,30 @@ hi! link asciidocQuotedUnconstrainedBold asciidocQuotedBold
372368
hi! link asciidocQuotedUnconstrainedEmphasized asciidocQuotedEmphasized
373369
hi! link asciidocURL markdownUrl
374370

375-
" JSON:
371+
" JSON (built-in)
376372
call <sid>hi('jsonKeyword', s:cdLightBlue, {}, 'none', {})
377373
call <sid>hi('jsonEscape', s:cdYellowOrange, {}, 'none', {})
378374
call <sid>hi('jsonNull', s:cdBlue, {}, 'none', {})
379375
call <sid>hi('jsonBoolean', s:cdBlue, {}, 'none', {})
380376

381-
" HTML:
377+
" HTML (built-in)
382378
call <sid>hi('htmlTag', s:cdGray, {}, 'none', {})
383379
call <sid>hi('htmlEndTag', s:cdGray, {}, 'none', {})
384380
call <sid>hi('htmlTagName', s:cdBlue, {}, 'none', {})
385-
call <sid>hi('htmlSpecialTagName', s:cdBlue, {}, 'none', {})
381+
hi! link htmlSpecialTagName htmlTagName
386382
call <sid>hi('htmlArg', s:cdLightBlue, {}, 'none', {})
387383

388-
" PHP:
389-
call <sid>hi('phpStaticClasses', s:cdBlueGreen, {}, 'none', {})
390-
call <sid>hi('phpMethod', s:cdYellow, {}, 'none', {})
384+
" PHP (built-in)
391385
call <sid>hi('phpClass', s:cdBlueGreen, {}, 'none', {})
386+
hi! link phpUseClass phpClass
387+
hi! link phpStaticClasses phpClass
388+
call <sid>hi('phpMethod', s:cdYellow, {}, 'none', {})
392389
call <sid>hi('phpFunction', s:cdYellow, {}, 'none', {})
393390
call <sid>hi('phpInclude', s:cdBlue, {}, 'none', {})
394-
call <sid>hi('phpUseClass', s:cdBlueGreen, {}, 'none', {})
395391
call <sid>hi('phpRegion', s:cdBlueGreen, {}, 'none', {})
396392
call <sid>hi('phpMethodsVar', s:cdLightBlue, {}, 'none', {})
397393

398-
" CSS:
394+
" CSS (built-in)
399395
call <sid>hi('cssBraces', s:cdFront, {}, 'none', {})
400396
call <sid>hi('cssInclude', s:cdPink, {}, 'none', {})
401397
call <sid>hi('cssTagName', s:cdBlue, {}, 'none', {})
@@ -581,16 +577,16 @@ call <sid>hi('texBeginEndModifier', s:cdLightBlue, {}, 'none', {})
581577
call <sid>hi('texDocType', s:cdPink, {}, 'none', {})
582578
call <sid>hi('texDocTypeArgs', s:cdLightBlue, {}, 'none', {})
583579

584-
" Git:
580+
" GIT (built-in)
585581
call <sid>hi('gitcommitHeader', s:cdGray, {}, 'none', {})
586582
call <sid>hi('gitcommitOnBranch', s:cdGray, {}, 'none', {})
587583
call <sid>hi('gitcommitBranch', s:cdPink, {}, 'none', {})
588584
call <sid>hi('gitcommitComment', s:cdGray, {}, 'none', {})
589585
call <sid>hi('gitcommitSelectedType', s:cdGreen, {}, 'none', {})
590-
call <sid>hi('gitcommitSelectedFile', s:cdGreen, {}, 'none', {})
586+
hi! link gitcommitSelectedFile gitcommitSelectedType
591587
call <sid>hi('gitcommitDiscardedType', s:cdRed, {}, 'none', {})
592-
call <sid>hi('gitcommitDiscardedFile', s:cdRed, {}, 'none', {})
593-
call <sid>hi('gitcommitOverflow', s:cdRed, {}, 'none', {})
588+
hi! link gitcommitDiscardedFile gitcommitDiscardedType
589+
hi! link gitcommitOverflow gitcommitDiscardedType
594590
call <sid>hi('gitcommitSummary', s:cdPink, {}, 'none', {})
595591
call <sid>hi('gitcommitBlank', s:cdPink, {}, 'none', {})
596592

@@ -601,7 +597,6 @@ call <sid>hi('luaFuncKeyword', s:cdPink, {}, 'none', {})
601597
call <sid>hi('luaLocal', s:cdPink, {}, 'none', {})
602598
call <sid>hi('luaBuiltIn', s:cdBlue, {}, 'none', {})
603599

604-
605600
" SH:
606601
call <sid>hi('shDeref', s:cdLightBlue, {}, 'none', {})
607602
call <sid>hi('shVariable', s:cdLightBlue, {}, 'none', {})

0 commit comments

Comments
 (0)