@@ -8,7 +8,7 @@ set cpo&vim
88func ! Test_check_colors ()
99 let l: savedview = winsaveview ()
1010 call cursor (1 ,1 )
11- let err= {}
11+ let err = {}
1212
1313 " 1) Check g:colors_name is existing
1414 if ! search (' \<\%(g:\)\?colors_name\>' , ' cnW' )
@@ -81,36 +81,39 @@ func! Test_check_colors()
8181 \ ' WarningMsg' ,
8282 \ ' WildMenu' ,
8383 \ ]
84- let groups= {}
84+ let groups = {}
8585 for group in hi_groups
86- if search (' \c@suppress\s\+' . group, ' cnW' )
86+ if search (' \c@suppress\s\+\< ' .. group .. ' \> ' , ' cnW' )
8787 " skip check, if the script contains a line like
8888 " @suppress Visual:
89- let groups[group] = ' Ignoring ' .group
9089 continue
9190 endif
92- if search (' hi\%[ghlight]!\= \+link \+' . group, ' cnW' ) " Linked group
91+ if search (' hi\%[ghlight]!\= \+link \+' .. group, ' cnW' ) " Linked group
9392 continue
9493 endif
95- if ! search (' hi\%[ghlight] \+' . group, ' cnW' )
96- let groups[group] = ' No highlight definition for ' . group
94+ if ! search (' hi\%[ghlight] \+\< ' .. group .. ' \> ' , ' cnW' )
95+ let groups[group] = ' No highlight definition for ' .. group
9796 continue
9897 endif
99- if ! search (' hi\%[ghlight] \+' . group. ' .*fg =' , ' cnW' )
100- let groups[group] = ' Missing foreground color for ' . group
98+ if ! search (' hi\%[ghlight] \+\< ' .. group .. ' \>.*[bf]g =' , ' cnW' )
99+ let groups[group] = ' Missing foreground or background color for ' .. group
101100 continue
102101 endif
103- if search (' hi\%[ghlight] \+' .group. ' .*guibg=' , ' cnW' ) &&
104- \ ! search (' hi\%[ghlight] \+' .group. ' .*ctermbg=' , ' cnW' )
105- let groups[group] = ' Missing bg terminal color for ' .group
102+ if search (' hi\%[ghlight] \+\<' .. group .. ' \>.*guibg=' , ' cnW' ) &&
103+ \ ! search (' hi\%[ghlight] \+\<' .. group .. ' \>.*ctermbg=' , ' cnW' )
104+ \ && group != ' Cursor'
105+ let groups[group] = ' Missing bg terminal color for ' .. group
106106 continue
107107 endif
108- if ! search (' hi\%[ghlight] \+' .group. ' .*guifg=' , ' cnW' )
109- let groups[group] = ' Missing guifg definition for ' .group
108+ if ! search (' hi\%[ghlight] \+\<' .. group .. ' \>.*guifg=' , ' cnW' )
109+ \ && group !~ ' ^Diff'
110+ let groups[group] = ' Missing guifg definition for ' .. group
110111 continue
111112 endif
112- if ! search (' hi\%[ghlight] \+' .group. ' .*ctermfg=' , ' cnW' )
113- let groups[group] = ' Missing ctermfg definition for ' .group
113+ if ! search (' hi\%[ghlight] \+\<' .. group .. ' \>.*ctermfg=' , ' cnW' )
114+ \ && group !~ ' ^Diff'
115+ \ && group != ' Cursor'
116+ let groups[group] = ' Missing ctermfg definition for ' .. group
114117 continue
115118 endif
116119 " do not check for background colors, they could be intentionally left out
@@ -120,10 +123,10 @@ func! Test_check_colors()
120123
121124 " 3) Check, that it does not set background highlighting
122125 " Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes?
123- let bg_set= ' \(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
124- let bg_let= ' let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\(['' "]\?\)\w\+\1'
125- let bg_pat= ' \%(' . bg_set. ' \|' . bg_let. ' \)'
126- let line = search (bg_pat, ' cnW' )
126+ let bg_set = ' \(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
127+ let bg_let = ' let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\(['' "]\?\)\w\+\1'
128+ let bg_pat = ' \%(' .. bg_set .. ' \|' .. bg_let .. ' \)'
129+ let line = search (bg_pat, ' cnW' )
127130 if search (bg_pat, ' cnW' )
128131 exe line
129132 if search (' hi \U\w\+\s\+\S' , ' cbnW' )
@@ -145,7 +148,7 @@ func! Test_check_colors()
145148 " if exists("syntax_on")
146149 " syntax reset
147150 " endif
148- let pat= ' hi\%[ghlight]\s*clear\n\s*if\s*exists(\(['' "]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif'
151+ let pat = ' hi\%[ghlight]\s*clear\n\s*if\s*exists(\(['' "]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif'
149152 if ! search (pat, ' cnW' )
150153 let err[' init' ] = ' No initialization'
151154 endif
@@ -160,7 +163,7 @@ func! Test_check_colors()
160163 let ft_groups = []
161164 " let group = '\%('.join(hi_groups, '\|').'\)' " More efficient than a for loop, but less informative
162165 for group in hi_groups
163- let pat= ' \Chi\%[ghlight]!\= *\%[link] \+\zs' . group. ' \w\+\>\ze \+.' " Skips `hi clear`
166+ let pat = ' \Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. ' \w\+\>\ze \+.' " Skips `hi clear`
164167 if search (pat, ' cW' )
165168 call add (ft_groups, matchstr (getline (' .' ), pat))
166169 endif
@@ -172,7 +175,7 @@ func! Test_check_colors()
172175
173176 " 8) Were debugPC and debugBreakpoint defined?
174177 for group in [' debugPC' , ' debugBreakpoint' ]
175- let pat= ' \Chi\%[ghlight]!\= *\%[link] \+\zs' . group. ' \>'
178+ let pat = ' \Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. ' \>'
176179 if search (pat, ' cnW' )
177180 let line = search (pat, ' cW' )
178181 let err[' filetype' ] = get (err, ' filetype' , ' Should not define: ' ) . matchstr (getline (' .' ), pat). ' '
0 commit comments