1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
let s:suite = themis#suite('highlight')
let s:assert = themis#helper('assert')
function! s:suite.before_each()
hi clear
endfunction
function! s:hi(name)
redir => hi
silent! exec 'hi' a:name
redir END
return substitute(join(split(hi, "\n"), ''), ' \+', ' ', 'g')
endfunction
function! s:pattern(xs, ...) abort
let ys = a:0 ? a:xs[1:] : a:xs
let zs = get(a:000, 0, a:xs)
return 'ctermfg=' . ys[2] . ' ctermbg=' . zs[3] . '.*guifg=' . ys[0] . ' guibg=' . zs[1]
endfunction
function! s:suite.highlight()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightLineLeft_normal_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_normal_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.insert()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('insert')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_insert_0'), s:pattern(palette.insert.left[0]))
call s:assert.match(s:hi('LightLineLeft_insert_1'), s:pattern(palette.insert.left[1]))
call s:assert.match(s:hi('LightLineLeft_insert_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_insert_0'), s:pattern(palette.insert.right[0]))
call s:assert.match(s:hi('LightLineRight_insert_1'), s:pattern(palette.insert.right[1]))
call s:assert.match(s:hi('LightLineRight_insert_2'), s:pattern(palette.insert.right[2]))
call s:assert.match(s:hi('LightLineRight_insert_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_insert'), s:pattern(palette.insert.middle[0]))
endfunction
function! s:suite.visual()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('visual')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_visual_0'), s:pattern(palette.visual.left[0]))
call s:assert.match(s:hi('LightLineLeft_visual_1'), s:pattern(palette.visual.left[1]))
call s:assert.match(s:hi('LightLineLeft_visual_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_visual_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_visual_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_visual_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_visual_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.replace()
let g:lightline = {}
call lightline#init()
call lightline#colorscheme()
call lightline#highlight('replace')
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_replace_0'), s:pattern(palette.replace.left[0]))
call s:assert.match(s:hi('LightLineLeft_replace_1'), s:pattern(palette.replace.left[1]))
call s:assert.match(s:hi('LightLineLeft_replace_2'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_replace_0'), s:pattern(palette.replace.right[0]))
call s:assert.match(s:hi('LightLineRight_replace_1'), s:pattern(palette.replace.right[1]))
call s:assert.match(s:hi('LightLineRight_replace_2'), s:pattern(palette.replace.right[2]))
call s:assert.match(s:hi('LightLineRight_replace_3'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_replace'), s:pattern(palette.replace.middle[0]))
endfunction
function! s:suite.left_right()
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ]
\ },
\ }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), s:pattern(palette.normal.left[1]))
call s:assert.match(s:hi('LightLineLeft_normal_2'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineLeft_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineLeft_normal_4'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), s:pattern(palette.normal.right[1]))
call s:assert.match(s:hi('LightLineRight_normal_2'), s:pattern(palette.normal.right[2]))
call s:assert.match(s:hi('LightLineRight_normal_3'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineRight_normal_4'), s:pattern(palette.normal.middle[0]))
call s:assert.match(s:hi('LightLineRight_normal_5'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.no_components()
let g:lightline = {
\ 'active': {
\ 'left': [],
\ 'right': []
\ },
\ 'inactive': {
\ 'left': [],
\ 'right': []
\ },
\ }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
call s:assert.match(s:hi('LightLineLeft_normal_0'), s:pattern(palette.normal.left[0]))
call s:assert.match(s:hi('LightLineLeft_normal_1'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineRight_normal_0'), s:pattern(palette.normal.right[0]))
call s:assert.match(s:hi('LightLineRight_normal_1'), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi('LightLineMiddle_normal'), s:pattern(palette.normal.middle[0]))
endfunction
function! s:suite.subseparator()
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly' ], [ 'filename' ], [ 'modified' ] ],
\ 'right': [ [ 'lineinfo' ], [ 'percent' ], [ 'fileformat' ], [ 'fileencoding' ], [ 'filetype' ] ]
\ },
\ }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
for i in range(4)
for j in range(5)
if i + 1 == j
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), s:pattern(get(palette.normal.left, i, palette.normal.middle[0]), get(palette.normal.left, j, palette.normal.middle[0])))
else
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', i, j)), 'E411: highlight group not found\|cleared')
endif
endfor
endfor
endfunction
function! s:suite.component_type()
let g:lightline = { 'component_type': { 'error': 'error', 'warning': 'warning' } }
call lightline#init()
call lightline#colorscheme()
let palette = lightline#palette()
for type in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s', type)), s:pattern(palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_0_%s', type)), s:pattern(palette.normal.left[0], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_1_%s', type)), s:pattern(palette.normal.left[1], palette.normal[type][0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_2_%s', type)), 'E411: highlight group not found\|cleared')
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_0', type)), s:pattern(palette.normal[type][0], palette.normal.left[0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_1', type)), s:pattern(palette.normal[type][0], palette.normal.left[1]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_2', type)), s:pattern(palette.normal[type][0], palette.normal.middle[0]))
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_3', type)), 'E411: highlight group not found\|cleared')
endfor
for type1 in ['error', 'warning']
for type2 in ['error', 'warning']
call s:assert.match(s:hi(printf('LightLineLeft_normal_%s_%s', type1, type2)), s:pattern(palette.normal[type1][0], palette.normal[type2][0]))
endfor
endfor
endfunction
|