mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.1.1674: script to check a colorscheme can be improved
Problem: Script to check a colorscheme can be improved. Solution: Match the whole group name. Don't warn for what is usually omitted.
This commit is contained in:
parent
b4f0628fc5
commit
4e63f9425e
@ -83,34 +83,37 @@ func! Test_check_colors()
|
|||||||
\ ]
|
\ ]
|
||||||
let groups = {}
|
let groups = {}
|
||||||
for group in hi_groups
|
for group in hi_groups
|
||||||
if search('\c@suppress\s\+'.group, 'cnW')
|
if search('\c@suppress\s\+\<' .. group .. '\>', 'cnW')
|
||||||
" skip check, if the script contains a line like
|
" skip check, if the script contains a line like
|
||||||
" @suppress Visual:
|
" @suppress Visual:
|
||||||
let groups[group] = 'Ignoring '.group
|
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
if search('hi\%[ghlight]!\= \+link \+'.group, 'cnW') " Linked group
|
if search('hi\%[ghlight]!\= \+link \+' .. group, 'cnW') " Linked group
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
if !search('hi\%[ghlight] \+'.group, 'cnW')
|
if !search('hi\%[ghlight] \+\<' .. group .. '\>', 'cnW')
|
||||||
let groups[group] = 'No highlight definition for '.group
|
let groups[group] = 'No highlight definition for ' .. group
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
if !search('hi\%[ghlight] \+'.group. '.*fg=', 'cnW')
|
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*[bf]g=', 'cnW')
|
||||||
let groups[group] = 'Missing foreground color for '.group
|
let groups[group] = 'Missing foreground or background color for ' .. group
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
if search('hi\%[ghlight] \+'.group. '.*guibg=', 'cnW') &&
|
if search('hi\%[ghlight] \+\<' .. group .. '\>.*guibg=', 'cnW') &&
|
||||||
\ !search('hi\%[ghlight] \+'.group. '.*ctermbg=', 'cnW')
|
\ !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermbg=', 'cnW')
|
||||||
let groups[group] = 'Missing bg terminal color for '.group
|
\ && group != 'Cursor'
|
||||||
|
let groups[group] = 'Missing bg terminal color for ' .. group
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
if !search('hi\%[ghlight] \+'.group. '.*guifg=', 'cnW')
|
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*guifg=', 'cnW')
|
||||||
let groups[group] = 'Missing guifg definition for '.group
|
\ && group !~ '^Diff'
|
||||||
|
let groups[group] = 'Missing guifg definition for ' .. group
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
if !search('hi\%[ghlight] \+'.group. '.*ctermfg=', 'cnW')
|
if !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermfg=', 'cnW')
|
||||||
let groups[group] = 'Missing ctermfg definition for '.group
|
\ && group !~ '^Diff'
|
||||||
|
\ && group != 'Cursor'
|
||||||
|
let groups[group] = 'Missing ctermfg definition for ' .. group
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
" do not check for background colors, they could be intentionally left out
|
" do not check for background colors, they could be intentionally left out
|
||||||
@ -122,7 +125,7 @@ func! Test_check_colors()
|
|||||||
" Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes?
|
" Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes?
|
||||||
let bg_set = '\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
|
let bg_set = '\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
|
||||||
let bg_let = 'let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1'
|
let bg_let = 'let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1'
|
||||||
let bg_pat='\%('.bg_set. '\|'.bg_let.'\)'
|
let bg_pat = '\%(' .. bg_set .. '\|' .. bg_let .. '\)'
|
||||||
let line = search(bg_pat, 'cnW')
|
let line = search(bg_pat, 'cnW')
|
||||||
if search(bg_pat, 'cnW')
|
if search(bg_pat, 'cnW')
|
||||||
exe line
|
exe line
|
||||||
@ -160,7 +163,7 @@ func! Test_check_colors()
|
|||||||
let ft_groups = []
|
let ft_groups = []
|
||||||
" let group = '\%('.join(hi_groups, '\|').'\)' " More efficient than a for loop, but less informative
|
" let group = '\%('.join(hi_groups, '\|').'\)' " More efficient than a for loop, but less informative
|
||||||
for group in hi_groups
|
for group in hi_groups
|
||||||
let pat='\Chi\%[ghlight]!\= *\%[link] \+\zs'.group.'\w\+\>\ze \+.' " Skips `hi clear`
|
let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\w\+\>\ze \+.' " Skips `hi clear`
|
||||||
if search(pat, 'cW')
|
if search(pat, 'cW')
|
||||||
call add(ft_groups, matchstr(getline('.'), pat))
|
call add(ft_groups, matchstr(getline('.'), pat))
|
||||||
endif
|
endif
|
||||||
@ -172,7 +175,7 @@ func! Test_check_colors()
|
|||||||
|
|
||||||
" 8) Were debugPC and debugBreakpoint defined?
|
" 8) Were debugPC and debugBreakpoint defined?
|
||||||
for group in ['debugPC', 'debugBreakpoint']
|
for group in ['debugPC', 'debugBreakpoint']
|
||||||
let pat='\Chi\%[ghlight]!\= *\%[link] \+\zs'.group.'\>'
|
let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\>'
|
||||||
if search(pat, 'cnW')
|
if search(pat, 'cnW')
|
||||||
let line = search(pat, 'cW')
|
let line = search(pat, 'cW')
|
||||||
let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' '
|
let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' '
|
||||||
|
@ -777,6 +777,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1674,
|
||||||
/**/
|
/**/
|
||||||
1673,
|
1673,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user