annotate runtime/colors/tools/check_colors.vim @ 20601:75ef263d09d6 v8.2.0854

patch 8.2.0854: xxd cannot show offset as a decimal number Commit: https://github.com/vim/vim/commit/363d6148dfc2cc17fb0d286c7a36c305f56f5813 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 30 20:50:25 2020 +0200 patch 8.2.0854: xxd cannot show offset as a decimal number Problem: Xxd cannot show offset as a decimal number. Solution: Add the "-d" flag. (Aapo Rantalainen, closes https://github.com/vim/vim/issues/5616
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 May 2020 21:00:12 +0200
parents 072ae5089541
children 0db0640e16e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
1 " This script tests a color scheme for some errors and lists potential errors.
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
2 " Load the scheme and source this script, like this:
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
3 " :edit colors/desert.vim | :so colors/tools/check_colors.vim
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 let s:save_cpo= &cpo
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 set cpo&vim
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func! Test_check_colors()
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
9 let l:savedview = winsaveview()
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 call cursor(1,1)
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
11 let err = {}
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " 1) Check g:colors_name is existing
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 if !search('\<\%(g:\)\?colors_name\>', 'cnW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let err['colors_name'] = 'g:colors_name not set'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 else
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 let err['colors_name'] = 'OK'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 " 2) Check for some well-defined highlighting groups
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
21 let hi_groups = [
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
22 \ 'ColorColumn',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
23 \ 'Comment',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
24 \ 'Conceal',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
25 \ 'Constant',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
26 \ 'Cursor',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
27 \ 'CursorColumn',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
28 \ 'CursorLine',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
29 \ 'CursorLineNr',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
30 \ 'DiffAdd',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
31 \ 'DiffChange',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
32 \ 'DiffDelete',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
33 \ 'DiffText',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
34 \ 'Directory',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
35 \ 'EndOfBuffer',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
36 \ 'Error',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
37 \ 'ErrorMsg',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
38 \ 'FoldColumn',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
39 \ 'Folded',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
40 \ 'Identifier',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
41 \ 'Ignore',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
42 \ 'IncSearch',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
43 \ 'LineNr',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
44 \ 'MatchParen',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
45 \ 'ModeMsg',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
46 \ 'MoreMsg',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
47 \ 'NonText',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
48 \ 'Normal',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
49 \ 'Pmenu',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
50 \ 'PmenuSbar',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
51 \ 'PmenuSel',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
52 \ 'PmenuThumb',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
53 \ 'PreProc',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
54 \ 'Question',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
55 \ 'QuickFixLine',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
56 \ 'Search',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
57 \ 'SignColumn',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
58 \ 'Special',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
59 \ 'SpecialKey',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
60 \ 'SpellBad',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
61 \ 'SpellCap',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
62 \ 'SpellLocal',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
63 \ 'SpellRare',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
64 \ 'Statement',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
65 \ 'StatusLine',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
66 \ 'StatusLineNC',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
67 \ 'StatusLineTerm',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
68 \ 'StatusLineTermNC',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
69 \ 'TabLine',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
70 \ 'TabLineFill',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
71 \ 'TabLineSel',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
72 \ 'Title',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
73 \ 'Todo',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
74 \ 'ToolbarButton',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
75 \ 'ToolbarLine',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
76 \ 'Type',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
77 \ 'Underlined',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
78 \ 'VertSplit',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
79 \ 'Visual',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
80 \ 'VisualNOS',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
81 \ 'WarningMsg',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
82 \ 'WildMenu',
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
83 \ ]
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
84 let groups = {}
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 for group in hi_groups
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
86 if search('\c@suppress\s\+\<' .. group .. '\>', 'cnW')
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 " skip check, if the script contains a line like
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 " @suppress Visual:
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 continue
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 endif
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
91 if search('hi\%[ghlight]!\= \+link \+' .. group, 'cnW') " Linked group
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
92 continue
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
93 endif
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
94 if !search('hi\%[ghlight] \+\<' .. group .. '\>', 'cnW')
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
95 let groups[group] = 'No highlight definition for ' .. group
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 continue
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 endif
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
98 if !search('hi\%[ghlight] \+\<' .. group .. '\>.*[bf]g=', 'cnW')
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
99 let groups[group] = 'Missing foreground or background color for ' .. group
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
100 continue
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
101 endif
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
102 if search('hi\%[ghlight] \+\<' .. group .. '\>.*guibg=', 'cnW') &&
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
103 \ !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermbg=', 'cnW')
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
104 \ && group != 'Cursor'
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
105 let groups[group] = 'Missing bg terminal color for ' .. group
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 continue
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 endif
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
108 if !search('hi\%[ghlight] \+\<' .. group .. '\>.*guifg=', 'cnW')
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
109 \ && group !~ '^Diff'
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
110 let groups[group] = 'Missing guifg definition for ' .. group
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 continue
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 endif
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
113 if !search('hi\%[ghlight] \+\<' .. group .. '\>.*ctermfg=', 'cnW')
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
114 \ && group !~ '^Diff'
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
115 \ && group != 'Cursor'
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
116 let groups[group] = 'Missing ctermfg definition for ' .. group
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
117 continue
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
118 endif
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
119 " do not check for background colors, they could be intentionally left out
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 call cursor(1,1)
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 endfor
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 let err['highlight'] = groups
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
124 " 3) Check, that it does not set background highlighting
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
125 " Doesn't ':hi Normal ctermfg=253 ctermfg=233' also set the background sometimes?
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
126 let bg_set = '\(set\?\|setl\(ocal\)\?\) .*\(background\|bg\)=\(dark\|light\)'
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
127 let bg_let = 'let \%([&]\%([lg]:\)\?\)\%(background\|bg\)\s*=\s*\([''"]\?\)\w\+\1'
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
128 let bg_pat = '\%(' .. bg_set .. '\|' .. bg_let .. '\)'
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
129 let line = search(bg_pat, 'cnW')
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 if search(bg_pat, 'cnW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 exe line
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 if search('hi \U\w\+\s\+\S', 'cbnW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 let err['background'] = 'Should not set background option after :hi statement'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
134 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 else
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 let err['background'] = 'OK'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 call cursor(1,1)
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 " 4) Check, that t_Co is checked
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141 let pat = '[&]t_Co\s*[<>=]=\?\s*\d\+'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 if !search(pat, 'ncW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
143 let err['t_Co'] = 'Does not check terminal for capable colors'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
145
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
146 " 5) Initializes correctly, e.g. should have a section like
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 " hi clear
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 " if exists("syntax_on")
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 " syntax reset
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 " endif
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
151 let pat = 'hi\%[ghlight]\s*clear\n\s*if\s*exists(\([''"]\)syntax_on\1)\n\s*syn\%[tax]\s*reset\n\s*endif'
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 if !search(pat, 'cnW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 let err['init'] = 'No initialization'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 " 6) Does not use :syn on
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 if search('syn\%[tax]\s\+on', 'cnW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 let err['background'] = 'Should not issue :syn on'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160
14123
583bf95b6c84 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 14006
diff changeset
161 " 7) Does not define filetype specific groups like vimCommand, htmlTag,
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
162 let hi_groups = filter(getcompletion('', 'filetype'), { _,v -> v !~# '\%[no]syn\%(color\|load\|tax\)' })
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
163 let ft_groups = []
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
164 " let group = '\%('.join(hi_groups, '\|').'\)' " More efficient than a for loop, but less informative
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
165 for group in hi_groups
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
166 let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\w\+\>\ze \+.' " Skips `hi clear`
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
167 if search(pat, 'cW')
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
168 call add(ft_groups, matchstr(getline('.'), pat))
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
169 endif
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
170 call cursor(1,1)
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
171 endfor
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
172 if !empty(ft_groups)
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
173 let err['filetype'] = get(err, 'filetype', 'Should not define: ') . join(uniq(sort(ft_groups)))
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
174 endif
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
175
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
176 " 8) Were debugPC and debugBreakpoint defined?
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
177 for group in ['debugPC', 'debugBreakpoint']
17350
072ae5089541 patch 8.1.1674: script to check a colorscheme can be improved
Bram Moolenaar <Bram@vim.org>
parents: 16808
diff changeset
178 let pat = '\Chi\%[ghlight]!\= *\%[link] \+\zs' .. group .. '\>'
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 if search(pat, 'cnW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 let line = search(pat, 'cW')
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 let err['filetype'] = get(err, 'filetype', 'Should not define: ') . matchstr(getline('.'), pat). ' '
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 call cursor(1,1)
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 endfor
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
185
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
186 " 9) Normal should be defined first, not use reverse, fg or bg
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
187 call cursor(1,1)
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
188 let pat = 'hi\%[light] \+\%(link\|clear\)\@!\w\+\>'
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
189 call search(pat, 'cW') " Look for the first hi def, skipping `hi link` and `hi clear`
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
190 if getline('.') !~# '\m\<Normal\>'
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
191 let err['highlight']['Normal'] = 'Should be defined first'
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
192 elseif getline('.') =~# '\m\%(=\%(fg\|bg\)\)'
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
193 let err['highlight']['Normal'] = "Should not use 'fg' or 'bg'"
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
194 elseif getline('.') =~# '\m=\%(inv\|rev\)erse'
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
195 let err['highlight']['Normal'] = 'Should not use reverse mode'
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
196 endif
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
197
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
198 call winrestview(l:savedview)
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 let g:err = err
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
200
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 " print Result
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 call Result(err)
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 endfu
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 fu! Result(err)
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
206 let do_groups = 0
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 echohl Title|echomsg "---------------"|echohl Normal
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 for key in sort(keys(a:err))
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 if key is# 'highlight'
16808
c002c4899529 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14123
diff changeset
210 let do_groups = !empty(a:err[key])
13049
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 continue
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
212 else
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 if a:err[key] !~ 'OK'
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
214 echohl Title
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
216 echomsg printf("%15s: %s", key, a:err[key])
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 echohl Normal
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 endfor
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 echohl Title|echomsg "---------------"|echohl Normal
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 if do_groups
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 echohl Title | echomsg "Groups" | echohl Normal
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 for v1 in sort(keys(a:err['highlight']))
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 echomsg printf("%25s: %s", v1, a:err['highlight'][v1])
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 endfor
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 endif
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227 endfu
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 call Test_check_colors()
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 let &cpo = s:save_cpo
0d23a49da746 patch 8.0.1400: color scheme check script shows up as color scheme
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 unlet s:save_cpo