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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local os = require('os')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, request, eq = helpers.execute, helpers.request, helpers.eq
if helpers.pending_win32(pending) then return end
describe('color scheme compatibility', function()
before_each(function()
clear()
end)
it('t_Co is set to 256 by default', function()
eq('256', request('vim_eval', '&t_Co'))
request('nvim_set_option', 't_Co', '88')
eq('88', request('vim_eval', '&t_Co'))
end)
end)
describe('manual syntax highlight', function()
-- When using manual syntax highlighting, it should be preserved even when
-- switching buffers... bug did only occur without :set hidden
-- Ref: vim patch 7.4.1236
local screen
before_each(function()
clear()
screen = Screen.new(20,5)
screen:attach()
--syntax highlight for vimcscripts "echo"
screen:set_default_attr_ids( {
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {bold=true, foreground=Screen.colors.Brown}
} )
end)
after_each(function()
screen:detach()
os.remove('Xtest-functional-ui-highlight.tmp.vim')
end)
it("works with buffer switch and 'hidden'", function()
execute('e tmp1.vim')
execute('e Xtest-functional-ui-highlight.tmp.vim')
execute('filetype on')
execute('syntax manual')
execute('set ft=vim')
execute('set syntax=ON')
feed('iecho 1<esc>0')
execute('set hidden')
execute('w')
execute('bn')
execute('bp')
screen:expect([[
{1:^echo} 1 |
{0:~ }|
{0:~ }|
{0:~ }|
<f 1 --100%-- col 1 |
]])
end)
it("works with buffer switch and 'nohidden'", function()
execute('e tmp1.vim')
execute('e Xtest-functional-ui-highlight.tmp.vim')
execute('filetype on')
execute('syntax manual')
execute('set ft=vim')
execute('set syntax=ON')
feed('iecho 1<esc>0')
execute('set nohidden')
execute('w')
execute('bn')
execute('bp')
screen:expect([[
{1:^echo} 1 |
{0:~ }|
{0:~ }|
{0:~ }|
<ht.tmp.vim" 1L, 7C |
]])
end)
end)
describe('Default highlight groups', function()
-- Test the default attributes for highlight groups shown by the :highlight
-- command
local screen
before_each(function()
clear()
screen = Screen.new()
screen:attach()
end)
after_each(function()
screen:detach()
end)
it('window status bar', function()
screen:set_default_attr_ids({
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {reverse = true, bold = true}, -- StatusLine
[2] = {reverse = true} -- StatusLineNC
})
execute('sp', 'vsp', 'vsp')
screen:expect([[
^ {2:|} {2:|} |
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{1:[No Name] }{2:[No Name] [No Name] }|
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{2:[No Name] }|
|
]])
-- navigate to verify that the attributes are properly moved
feed('<c-w>j')
screen:expect([[
{2:|} {2:|} |
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{2:[No Name] [No Name] [No Name] }|
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1:[No Name] }|
|
]])
-- note that when moving to a window with small width nvim will increase
-- the width of the new active window at the expense of a inactive window
-- (upstream vim has the same behavior)
feed('<c-w>k<c-w>l')
screen:expect([[
{2:|}^ {2:|} |
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{2:[No Name] }{1:[No Name] }{2:[No Name] }|
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{2:[No Name] }|
|
]])
feed('<c-w>l')
screen:expect([[
{2:|} {2:|}^ |
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{2:[No Name] [No Name] }{1:[No Name] }|
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{2:[No Name] }|
|
]])
feed('<c-w>h<c-w>h')
screen:expect([[
^ {2:|} {2:|} |
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{0:~ }{2:|}{0:~ }{2:|}{0:~ }|
{1:[No Name] }{2:[No Name] [No Name] }|
|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{2:[No Name] }|
|
]])
end)
it('insert mode text', function()
feed('i')
screen:expect([[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1:-- INSERT --} |
]], {[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {bold = true}})
end)
it('end of file markers', function()
screen:expect([[
^ |
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
{1:~ }|
|
]], {[1] = {bold = true, foreground = Screen.colors.Blue}})
end)
it('"wait return" text', function()
feed(':ls<cr>')
screen:expect([[
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
:ls |
1 %a "[No Name]" line 1 |
{1:Press ENTER or type command to continue}^ |
]], {[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {bold = true, foreground = Screen.colors.SeaGreen}})
feed('<cr>') -- skip the "Press ENTER..." state or tests will hang
end)
it('can be cleared and linked to other highlight groups', function()
execute('highlight clear ModeMsg')
feed('i')
screen:expect([[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
-- INSERT -- |
]], {[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {bold=true}})
feed('<esc>')
execute('highlight CustomHLGroup guifg=red guibg=green')
execute('highlight link ModeMsg CustomHLGroup')
feed('i')
screen:expect([[
^ |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{1:-- INSERT --} |
]], {[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {foreground = Screen.colors.Red, background = Screen.colors.Green}})
end)
it('can be cleared by assigning NONE', function()
execute('syn keyword TmpKeyword neovim')
execute('hi link TmpKeyword ErrorMsg')
insert('neovim')
screen:expect([[
{1:neovi^m} |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]], {
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {foreground = Screen.colors.White, background = Screen.colors.Red}
})
execute("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE"
.. " gui=NONE guifg=NONE guibg=NONE guisp=NONE")
screen:expect([[
neovi^m |
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
{0:~ }|
|
]], {[0] = {bold=true, foreground=Screen.colors.Blue}})
end)
end)
describe('guisp (special/undercurl)', function()
local screen
before_each(function()
clear()
screen = Screen.new(25,10)
screen:attach()
end)
it('can be set and is applied like foreground or background', function()
execute('syntax on')
execute('syn keyword TmpKeyword neovim')
execute('syn keyword TmpKeyword1 special')
execute('syn keyword TmpKeyword2 specialwithbg')
execute('syn keyword TmpKeyword3 specialwithfg')
execute('hi! Awesome guifg=red guibg=yellow guisp=red')
execute('hi! Awesome1 guisp=red')
execute('hi! Awesome2 guibg=yellow guisp=red')
execute('hi! Awesome3 guifg=red guisp=red')
execute('hi link TmpKeyword Awesome')
execute('hi link TmpKeyword1 Awesome1')
execute('hi link TmpKeyword2 Awesome2')
execute('hi link TmpKeyword3 Awesome3')
insert([[
neovim
awesome neovim
wordcontainingneovim
special
specialwithbg
specialwithfg
]])
feed('Go<tab>neovim tabbed')
screen:expect([[
{1:neovim} |
awesome {1:neovim} |
wordcontainingneovim |
{2:special} |
{3:specialwithbg} |
{4:specialwithfg} |
|
{1:neovim} tabbed^ |
{0:~ }|
{5:-- INSERT --} |
]],{
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red,
special = Screen.colors.Red},
[2] = {special = Screen.colors.Red},
[3] = {special = Screen.colors.Red, background = Screen.colors.Yellow},
[4] = {foreground = Screen.colors.Red, special = Screen.colors.Red},
[5] = {bold=true},
})
end)
end)
describe("'cursorline' with 'listchars'", function()
local screen
before_each(function()
clear()
screen = Screen.new(20,5)
screen:attach()
end)
after_each(function()
screen:detach()
end)
it("'cursorline' and 'cursorcolumn'", function()
screen:set_default_attr_ids({
[0] = {bold=true, foreground=Screen.colors.Blue},
[1] = {background=Screen.colors.Grey90}
})
execute('highlight clear ModeMsg')
execute('set cursorline')
feed('i')
screen:expect([[
{1:^ }|
{0:~ }|
{0:~ }|
{0:~ }|
-- INSERT -- |
]])
feed('abcdefg<cr>kkasdf')
screen:expect([[
abcdefg |
{1:kkasdf^ }|
{0:~ }|
{0:~ }|
-- INSERT -- |
]])
feed('<esc>')
screen:expect([[
abcdefg |
{1:kkasd^f }|
{0:~ }|
{0:~ }|
|
]])
execute('set nocursorline')
screen:expect([[
abcdefg |
kkasd^f |
{0:~ }|
{0:~ }|
:set nocursorline |
]])
feed('k')
screen:expect([[
abcde^fg |
kkasdf |
{0:~ }|
{0:~ }|
:set nocursorline |
]])
feed('jjji<cr><cr><cr><esc>')
screen:expect([[
kkasd |
|
|
^f |
|
]])
execute('set cursorline')
execute('set cursorcolumn')
feed('kkiabcdefghijk<esc>hh')
screen:expect([[
kkasd {1: } |
{1:abcdefgh^ijk }|
{1: } |
f {1: } |
|
]])
feed('khh')
screen:expect([[
{1:kk^asd }|
ab{1:c}defghijk |
{1: } |
f {1: } |
|
]])
end)
it("'cursorline' and with 'listchar' option: space, eol, tab, and trail", function()
screen:set_default_attr_ids({
[1] = {background=Screen.colors.Grey90},
[2] = {
foreground=Screen.colors.Red,
background=Screen.colors.Grey90,
},
[3] = {
background=Screen.colors.Grey90,
foreground=Screen.colors.Blue,
bold=true,
},
[4] = {
foreground=Screen.colors.Blue,
bold=true,
},
[5] = {
foreground=Screen.colors.Red,
},
})
execute('highlight clear ModeMsg')
execute('highlight SpecialKey guifg=#FF0000')
execute('set cursorline')
execute('set tabstop=8')
execute('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
feed('i\t abcd <cr>\t abcd <cr><esc>k')
screen:expect([[
{5:>-------.}abcd{5:*}{4:¬} |
{2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }|
{4:¬} |
{4:~ }|
|
]])
feed('k')
screen:expect([[
{2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }|
{5:>-------.}abcd{5:*}{4:¬} |
{4:¬} |
{4:~ }|
|
]])
execute('set nocursorline')
screen:expect([[
{5:^>-------.}abcd{5:*}{4:¬} |
{5:>-------.}abcd{5:*}{4:¬} |
{4:¬} |
{4:~ }|
:set nocursorline |
]])
execute('set nowrap')
feed('ALorem ipsum dolor sit amet<ESC>0')
screen:expect([[
{5:^>-------.}abcd{5:.}Lorem{4:>}|
{5:>-------.}abcd{5:*}{4:¬} |
{4:¬} |
{4:~ }|
|
]])
execute('set cursorline')
screen:expect([[
{2:^>-------.}{1:abcd}{2:.}{1:Lorem}{4:>}|
{5:>-------.}abcd{5:*}{4:¬} |
{4:¬} |
{4:~ }|
:set cursorline |
]])
feed('$')
screen:expect([[
{4:<}{1:r}{2:.}{1:sit}{2:.}{1:ame^t}{3:¬}{1: }|
{4:<} |
{4:<} |
{4:~ }|
:set cursorline |
]])
feed('G')
screen:expect([[
{5:>-------.}abcd{5:.}Lorem{4:>}|
{5:>-------.}abcd{5:*}{4:¬} |
{3:^¬}{1: }|
{4:~ }|
:set cursorline |
]])
end)
it("'listchar' in visual mode", function()
screen:set_default_attr_ids({
[1] = {background=Screen.colors.Grey90},
[2] = {
foreground=Screen.colors.Red,
background=Screen.colors.Grey90,
},
[3] = {
background=Screen.colors.Grey90,
foreground=Screen.colors.Blue,
bold=true,
},
[4] = {
foreground=Screen.colors.Blue,
bold=true,
},
[5] = {
foreground=Screen.colors.Red,
},
[6] = {
background=Screen.colors.LightGrey,
},
[7] = {
background=Screen.colors.LightGrey,
foreground=Screen.colors.Red,
},
[8] = {
background=Screen.colors.LightGrey,
foreground=Screen.colors.Blue,
bold=true,
},
})
execute('highlight clear ModeMsg')
execute('highlight SpecialKey guifg=#FF0000')
execute('set cursorline')
execute('set tabstop=8')
execute('set nowrap')
execute('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
feed('i\t abcd <cr>\t abcd Lorem ipsum dolor sit amet<cr><esc>kkk0')
screen:expect([[
{2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }|
{5:>-------.}abcd{5:.}Lorem{4:>}|
{4:¬} |
{4:~ }|
|
]])
feed('lllvj')
screen:expect([[
{5:>-------.}a{6:bcd}{7:*}{8:¬} |
{7:>-------.}{6:a}^bcd{5:.}Lorem{4:>}|
{4:¬} |
{4:~ }|
-- VISUAL -- |
]])
feed('<esc>V')
screen:expect([[
{5:>-------.}abcd{5:*}{4:¬} |
{7:>-------.}{6:a}^b{6:cd}{7:.}{6:Lorem}{4:>}|
{4:¬} |
{4:~ }|
-- VISUAL LINE -- |
]])
feed('<esc>$')
screen:expect([[
{4:<} |
{4:<}{1:r}{2:.}{1:sit}{2:.}{1:ame^t}{3:¬}{1: }|
{4:<} |
{4:~ }|
|
]])
end)
end)
|