highlight_spec.lua 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local Screen = require('test.functional.ui.screen')
  3. local os = require('os')
  4. local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
  5. local command = helpers.command
  6. local eval, exc_exec = helpers.eval, helpers.exc_exec
  7. local feed_command, eq = helpers.feed_command, helpers.eq
  8. local curbufmeths = helpers.curbufmeths
  9. describe('colorscheme compatibility', function()
  10. before_each(function()
  11. clear()
  12. end)
  13. it('t_Co is set to 256 by default', function()
  14. eq('256', eval('&t_Co'))
  15. end)
  16. end)
  17. describe('highlight: `:syntax manual`', function()
  18. -- When using manual syntax highlighting, it should be preserved even when
  19. -- switching buffers... bug did only occur without :set hidden
  20. -- Ref: vim patch 7.4.1236
  21. local screen
  22. before_each(function()
  23. clear()
  24. screen = Screen.new(20,5)
  25. screen:attach()
  26. --syntax highlight for vimcscripts "echo"
  27. screen:set_default_attr_ids( {
  28. [0] = {bold=true, foreground=Screen.colors.Blue},
  29. [1] = {bold=true, foreground=Screen.colors.Brown}
  30. } )
  31. end)
  32. after_each(function()
  33. os.remove('Xtest-functional-ui-highlight.tmp.vim')
  34. end)
  35. it("works with buffer switch and 'hidden'", function()
  36. command('e tmp1.vim')
  37. command('e Xtest-functional-ui-highlight.tmp.vim')
  38. command('filetype on')
  39. command('syntax manual')
  40. command('set ft=vim')
  41. command('set syntax=ON')
  42. feed('iecho 1<esc>0')
  43. command('set hidden')
  44. command('w')
  45. command('bn')
  46. feed_command('bp')
  47. screen:expect([[
  48. {1:^echo} 1 |
  49. {0:~ }|
  50. {0:~ }|
  51. {0:~ }|
  52. :bp |
  53. ]])
  54. end)
  55. it("works with buffer switch and 'nohidden'", function()
  56. command('e tmp1.vim')
  57. command('e Xtest-functional-ui-highlight.tmp.vim')
  58. command('filetype on')
  59. command('syntax manual')
  60. command('set filetype=vim fileformat=unix')
  61. command('set syntax=ON')
  62. feed('iecho 1<esc>0')
  63. command('set nohidden')
  64. command('w')
  65. command('silent bn')
  66. eq("tmp1.vim", eval("fnamemodify(bufname('%'), ':t')"))
  67. feed_command('silent bp')
  68. eq("Xtest-functional-ui-highlight.tmp.vim", eval("fnamemodify(bufname('%'), ':t')"))
  69. screen:expect([[
  70. {1:^echo} 1 |
  71. {0:~ }|
  72. {0:~ }|
  73. {0:~ }|
  74. :silent bp |
  75. ]])
  76. end)
  77. end)
  78. describe('highlight defaults', function()
  79. local screen
  80. before_each(function()
  81. clear()
  82. screen = Screen.new()
  83. screen:attach()
  84. command("set display-=msgsep")
  85. end)
  86. it('window status bar', function()
  87. screen:set_default_attr_ids({
  88. [0] = {bold=true, foreground=Screen.colors.Blue},
  89. [1] = {reverse = true, bold = true}, -- StatusLine
  90. [2] = {reverse = true} -- StatusLineNC
  91. })
  92. feed_command('sp', 'vsp', 'vsp')
  93. screen:expect([[
  94. ^ {2:│} {2:│} |
  95. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  96. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  97. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  98. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  99. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  100. {1:[No Name] }{2:[No Name] [No Name] }|
  101. |
  102. {0:~ }|
  103. {0:~ }|
  104. {0:~ }|
  105. {0:~ }|
  106. {2:[No Name] }|
  107. :vsp |
  108. ]])
  109. -- navigate to verify that the attributes are properly moved
  110. feed('<c-w>j')
  111. screen:expect([[
  112. {2:│} {2:│} |
  113. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  114. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  115. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  116. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  117. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  118. {2:[No Name] [No Name] [No Name] }|
  119. ^ |
  120. {0:~ }|
  121. {0:~ }|
  122. {0:~ }|
  123. {0:~ }|
  124. {1:[No Name] }|
  125. :vsp |
  126. ]])
  127. -- note that when moving to a window with small width nvim will increase
  128. -- the width of the new active window at the expense of a inactive window
  129. -- (upstream vim has the same behavior)
  130. feed('<c-w>k<c-w>l')
  131. screen:expect([[
  132. {2:│}^ {2:│} |
  133. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  134. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  135. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  136. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  137. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  138. {2:[No Name] }{1:[No Name] }{2:[No Name] }|
  139. |
  140. {0:~ }|
  141. {0:~ }|
  142. {0:~ }|
  143. {0:~ }|
  144. {2:[No Name] }|
  145. :vsp |
  146. ]])
  147. feed('<c-w>l')
  148. screen:expect([[
  149. {2:│} {2:│}^ |
  150. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  151. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  152. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  153. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  154. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  155. {2:[No Name] [No Name] }{1:[No Name] }|
  156. |
  157. {0:~ }|
  158. {0:~ }|
  159. {0:~ }|
  160. {0:~ }|
  161. {2:[No Name] }|
  162. :vsp |
  163. ]])
  164. feed('<c-w>h<c-w>h')
  165. screen:expect([[
  166. ^ {2:│} {2:│} |
  167. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  168. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  169. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  170. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  171. {0:~ }{2:│}{0:~ }{2:│}{0:~ }|
  172. {1:[No Name] }{2:[No Name] [No Name] }|
  173. |
  174. {0:~ }|
  175. {0:~ }|
  176. {0:~ }|
  177. {0:~ }|
  178. {2:[No Name] }|
  179. :vsp |
  180. ]])
  181. end)
  182. it('insert mode text', function()
  183. feed('i')
  184. screen:try_resize(53, 4)
  185. screen:expect([[
  186. ^ |
  187. {0:~ }|
  188. {0:~ }|
  189. {1:-- INSERT --} |
  190. ]], {[0] = {bold=true, foreground=Screen.colors.Blue},
  191. [1] = {bold = true}})
  192. end)
  193. it('end of file markers', function()
  194. screen:try_resize(53, 4)
  195. screen:expect([[
  196. ^ |
  197. {1:~ }|
  198. {1:~ }|
  199. |
  200. ]], {[1] = {bold = true, foreground = Screen.colors.Blue}})
  201. end)
  202. it('"wait return" text', function()
  203. screen:try_resize(53, 4)
  204. feed(':ls<cr>')
  205. screen:expect([[
  206. {0:~ }|
  207. :ls |
  208. 1 %a "[No Name]" line 1 |
  209. {1:Press ENTER or type command to continue}^ |
  210. ]], {[0] = {bold=true, foreground=Screen.colors.Blue},
  211. [1] = {bold = true, foreground = Screen.colors.SeaGreen}})
  212. feed('<cr>') -- skip the "Press ENTER..." state or tests will hang
  213. end)
  214. it('can be cleared and linked to other highlight groups', function()
  215. screen:try_resize(53, 4)
  216. feed_command('highlight clear ModeMsg')
  217. feed('i')
  218. screen:expect([[
  219. ^ |
  220. {0:~ }|
  221. {0:~ }|
  222. -- INSERT -- |
  223. ]], {[0] = {bold=true, foreground=Screen.colors.Blue},
  224. [1] = {bold=true}})
  225. feed('<esc>')
  226. feed_command('highlight CustomHLGroup guifg=red guibg=green')
  227. feed_command('highlight link ModeMsg CustomHLGroup')
  228. feed('i')
  229. screen:expect([[
  230. ^ |
  231. {0:~ }|
  232. {0:~ }|
  233. {1:-- INSERT --} |
  234. ]], {[0] = {bold=true, foreground=Screen.colors.Blue},
  235. [1] = {foreground = Screen.colors.Red, background = Screen.colors.Green}})
  236. end)
  237. it('can be cleared by assigning NONE', function()
  238. screen:try_resize(53, 4)
  239. feed_command('syn keyword TmpKeyword neovim')
  240. feed_command('hi link TmpKeyword ErrorMsg')
  241. insert('neovim')
  242. screen:expect([[
  243. {1:neovi^m} |
  244. {0:~ }|
  245. {0:~ }|
  246. |
  247. ]], {
  248. [0] = {bold=true, foreground=Screen.colors.Blue},
  249. [1] = {foreground = Screen.colors.White, background = Screen.colors.Red}
  250. })
  251. feed_command("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE"
  252. .. " gui=NONE guifg=NONE guibg=NONE guisp=NONE")
  253. screen:expect([[
  254. neovi^m |
  255. {0:~ }|
  256. {0:~ }|
  257. |
  258. ]], {[0] = {bold=true, foreground=Screen.colors.Blue}})
  259. end)
  260. it('Cursor after `:hi clear|syntax reset` #6508', function()
  261. command('highlight clear|syntax reset')
  262. eq('guifg=bg guibg=fg', eval([[matchstr(execute('hi Cursor'), '\v(gui|cterm).*$')]]))
  263. end)
  264. it('Whitespace highlight', function()
  265. screen:try_resize(53, 4)
  266. feed_command('highlight NonText gui=NONE guifg=#FF0000')
  267. feed_command('set listchars=space:.,tab:>-,trail:*,eol:¬ list')
  268. insert(' ne \t o\tv im ')
  269. screen:expect([[
  270. ne{0:.>----.}o{0:>-----}v{0:..}im{0:*^*¬} |
  271. {0:~ }|
  272. {0:~ }|
  273. |
  274. ]], {
  275. [0] = {foreground=Screen.colors.Red},
  276. [1] = {foreground=Screen.colors.Blue},
  277. })
  278. feed_command('highlight Whitespace gui=NONE guifg=#0000FF')
  279. screen:expect([[
  280. ne{1:.>----.}o{1:>-----}v{1:..}im{1:*^*}{0:¬} |
  281. {0:~ }|
  282. {0:~ }|
  283. :highlight Whitespace gui=NONE guifg=#0000FF |
  284. ]], {
  285. [0] = {foreground=Screen.colors.Red},
  286. [1] = {foreground=Screen.colors.Blue},
  287. })
  288. end)
  289. it('are sent to UIs', function()
  290. screen:try_resize(53, 4)
  291. screen:set_default_attr_ids({
  292. [0] = {},
  293. [1] = {bold = true, foreground = Screen.colors.Blue1},
  294. [2] = {bold = true, reverse = true},
  295. [3] = {italic=true}
  296. })
  297. screen:expect{grid=[[
  298. ^ |
  299. {1:~ }|
  300. {1:~ }|
  301. |
  302. ]], hl_groups={EndOfBuffer=1, MsgSeparator=2}}
  303. command('highlight EndOfBuffer gui=italic')
  304. screen:expect{grid=[[
  305. ^ |
  306. {3:~ }|
  307. {3:~ }|
  308. |
  309. ]], hl_groups={EndOfBuffer=3, MsgSeparator=2}}
  310. command('highlight clear EndOfBuffer')
  311. screen:expect{grid=[[
  312. ^ |
  313. {1:~ }|
  314. {1:~ }|
  315. |
  316. ]], hl_groups={EndOfBuffer=1, MsgSeparator=2}}
  317. end)
  318. end)
  319. describe('highlight', function()
  320. before_each(clear)
  321. it('visual', function()
  322. local screen = Screen.new(20,4)
  323. screen:attach()
  324. screen:set_default_attr_ids({
  325. [1] = {background = Screen.colors.LightGrey},
  326. [2] = {bold = true, foreground = Screen.colors.Blue1},
  327. [3] = {bold = true},
  328. })
  329. insert([[
  330. line1 foo bar
  331. ]])
  332. -- Non-blinking block cursor: does NOT highlight char-at-cursor.
  333. command('set guicursor=a:block-blinkon0')
  334. feed('gg$vhhh')
  335. screen:expect([[
  336. line1 foo^ {1:bar} |
  337. |
  338. {2:~ }|
  339. {3:-- VISUAL --} |
  340. ]])
  341. -- Vertical cursor: highlights char-at-cursor. #8983
  342. command('set guicursor=a:block-blinkon175')
  343. feed('<esc>gg$vhhh')
  344. screen:expect([[
  345. line1 foo{1:^ bar} |
  346. |
  347. {2:~ }|
  348. {3:-- VISUAL --} |
  349. ]])
  350. end)
  351. it('cterm=standout gui=standout', function()
  352. local screen = Screen.new(20,5)
  353. screen:attach()
  354. screen:set_default_attr_ids({
  355. [1] = {bold = true, foreground = Screen.colors.Blue1},
  356. [2] = {standout = true, bold = true, underline = true,
  357. background = Screen.colors.Gray90, foreground = Screen.colors.Blue1},
  358. [3] = {standout = true, underline = true,
  359. background = Screen.colors.Gray90}
  360. })
  361. feed_command('hi CursorLine cterm=standout,underline gui=standout,underline')
  362. feed_command('set cursorline')
  363. feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
  364. feed('i\t abcd <cr>\t abcd <cr><esc>k')
  365. screen:expect([[
  366. {1:>-------.}abcd{1:*¬} |
  367. {2:^>-------.}{3:abcd}{2:*¬}{3: }|
  368. {1:¬} |
  369. {1:~ }|
  370. |
  371. ]])
  372. end)
  373. it('strikethrough', function()
  374. local screen = Screen.new(25,6)
  375. screen:attach()
  376. feed_command('syntax on')
  377. feed_command('syn keyword TmpKeyword foo')
  378. feed_command('hi! Awesome cterm=strikethrough gui=strikethrough')
  379. feed_command('hi link TmpKeyword Awesome')
  380. insert([[
  381. foo
  382. foo bar
  383. foobarfoobar
  384. ]])
  385. screen:expect([[
  386. {1:foo} |
  387. {1:foo} bar |
  388. foobarfoobar |
  389. ^ |
  390. {2:~ }|
  391. |
  392. ]],{
  393. [1] = {strikethrough = true},
  394. [2] = {bold = true, foreground = Screen.colors.Blue1},
  395. })
  396. end)
  397. it('nocombine', function()
  398. local screen = Screen.new(25,6)
  399. screen:set_default_attr_ids{
  400. [1] = {foreground = Screen.colors.SlateBlue, underline = true},
  401. [2] = {bold = true, foreground = Screen.colors.Blue1},
  402. [3] = {underline = true, reverse = true, foreground = Screen.colors.SlateBlue},
  403. [4] = {background = Screen.colors.Yellow, reverse = true, foreground = Screen.colors.SlateBlue},
  404. [5] = {foreground = Screen.colors.Red},
  405. }
  406. screen:attach()
  407. feed_command('syntax on')
  408. feed_command('hi! Underlined cterm=underline gui=underline')
  409. feed_command('syn keyword Underlined foobar')
  410. feed_command('hi Search cterm=inverse,nocombine gui=inverse,nocombine')
  411. insert([[
  412. foobar
  413. foobar
  414. ]])
  415. screen:expect{grid=[[
  416. {1:foobar} |
  417. {1:foobar} |
  418. ^ |
  419. {2:~ }|
  420. {2:~ }|
  421. |
  422. ]]}
  423. feed('/foo')
  424. screen:expect{grid=[[
  425. {3:foo}{1:bar} |
  426. {4:foo}{1:bar} |
  427. |
  428. {2:~ }|
  429. {2:~ }|
  430. /foo^ |
  431. ]]}
  432. feed('<cr>')
  433. screen:expect{grid=[[
  434. {4:^foo}{1:bar} |
  435. {4:foo}{1:bar} |
  436. |
  437. {2:~ }|
  438. {2:~ }|
  439. {5:search hit...uing at TOP} |
  440. ]]}
  441. end)
  442. it('guisp (special/undercurl)', function()
  443. local screen = Screen.new(25,10)
  444. screen:attach()
  445. feed_command('syntax on')
  446. feed_command('syn keyword TmpKeyword neovim')
  447. feed_command('syn keyword TmpKeyword1 special')
  448. feed_command('syn keyword TmpKeyword2 specialwithbg')
  449. feed_command('syn keyword TmpKeyword3 specialwithfg')
  450. feed_command('hi! Awesome guifg=red guibg=yellow guisp=red')
  451. feed_command('hi! Awesome1 guisp=red')
  452. feed_command('hi! Awesome2 guibg=yellow guisp=red')
  453. feed_command('hi! Awesome3 guifg=red guisp=red')
  454. feed_command('hi link TmpKeyword Awesome')
  455. feed_command('hi link TmpKeyword1 Awesome1')
  456. feed_command('hi link TmpKeyword2 Awesome2')
  457. feed_command('hi link TmpKeyword3 Awesome3')
  458. insert([[
  459. neovim
  460. awesome neovim
  461. wordcontainingneovim
  462. special
  463. specialwithbg
  464. specialwithfg
  465. ]])
  466. feed('Go<tab>neovim tabbed')
  467. screen:expect([[
  468. {1:neovim} |
  469. awesome {1:neovim} |
  470. wordcontainingneovim |
  471. {2:special} |
  472. {3:specialwithbg} |
  473. {4:specialwithfg} |
  474. |
  475. {1:neovim} tabbed^ |
  476. {0:~ }|
  477. {5:-- INSERT --} |
  478. ]],{
  479. [0] = {bold=true, foreground=Screen.colors.Blue},
  480. [1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red,
  481. special = Screen.colors.Red},
  482. [2] = {special = Screen.colors.Red},
  483. [3] = {special = Screen.colors.Red, background = Screen.colors.Yellow},
  484. [4] = {foreground = Screen.colors.Red, special = Screen.colors.Red},
  485. [5] = {bold=true},
  486. })
  487. end)
  488. end)
  489. describe("'listchars' highlight", function()
  490. local screen
  491. before_each(function()
  492. clear()
  493. screen = Screen.new(20,5)
  494. screen:attach()
  495. end)
  496. it("'cursorline' and 'cursorcolumn'", function()
  497. screen:set_default_attr_ids({
  498. [0] = {bold=true, foreground=Screen.colors.Blue},
  499. [1] = {background=Screen.colors.Grey90}
  500. })
  501. feed_command('highlight clear ModeMsg')
  502. feed_command('set cursorline')
  503. feed('i')
  504. screen:expect([[
  505. {1:^ }|
  506. {0:~ }|
  507. {0:~ }|
  508. {0:~ }|
  509. -- INSERT -- |
  510. ]])
  511. feed('abcdefg<cr>kkasdf')
  512. screen:expect([[
  513. abcdefg |
  514. {1:kkasdf^ }|
  515. {0:~ }|
  516. {0:~ }|
  517. -- INSERT -- |
  518. ]])
  519. feed('<esc>')
  520. screen:expect([[
  521. abcdefg |
  522. {1:kkasd^f }|
  523. {0:~ }|
  524. {0:~ }|
  525. |
  526. ]])
  527. feed_command('set nocursorline')
  528. screen:expect([[
  529. abcdefg |
  530. kkasd^f |
  531. {0:~ }|
  532. {0:~ }|
  533. :set nocursorline |
  534. ]])
  535. feed('k')
  536. screen:expect([[
  537. abcde^fg |
  538. kkasdf |
  539. {0:~ }|
  540. {0:~ }|
  541. :set nocursorline |
  542. ]])
  543. feed('jjji<cr><cr><cr><esc>')
  544. screen:expect([[
  545. kkasd |
  546. |
  547. |
  548. ^f |
  549. |
  550. ]])
  551. feed_command('set cursorline')
  552. feed_command('set cursorcolumn')
  553. feed('kkiabcdefghijk<esc>hh')
  554. screen:expect([[
  555. kkasd {1: } |
  556. {1:abcdefgh^ijk }|
  557. {1: } |
  558. f {1: } |
  559. |
  560. ]])
  561. feed('khh')
  562. screen:expect([[
  563. {1:kk^asd }|
  564. ab{1:c}defghijk |
  565. {1: } |
  566. f {1: } |
  567. |
  568. ]])
  569. end)
  570. it("'cursorline' and with 'listchars' option", function()
  571. screen:set_default_attr_ids({
  572. [1] = {background=Screen.colors.Grey90},
  573. [2] = {
  574. foreground=Screen.colors.Red,
  575. background=Screen.colors.Grey90,
  576. },
  577. [3] = {
  578. background=Screen.colors.Grey90,
  579. foreground=Screen.colors.Blue,
  580. bold=true,
  581. },
  582. [4] = {
  583. foreground=Screen.colors.Blue,
  584. bold=true,
  585. },
  586. [5] = {
  587. foreground=Screen.colors.Red,
  588. },
  589. })
  590. feed_command('highlight clear ModeMsg')
  591. feed_command('highlight Whitespace guifg=#FF0000')
  592. feed_command('set cursorline')
  593. feed_command('set tabstop=8')
  594. feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
  595. feed('i\t abcd <cr>\t abcd <cr><esc>k')
  596. screen:expect([[
  597. {5:>-------.}abcd{5:*}{4:¬} |
  598. {2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }|
  599. {4:¬} |
  600. {4:~ }|
  601. |
  602. ]])
  603. feed('k')
  604. screen:expect([[
  605. {2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }|
  606. {5:>-------.}abcd{5:*}{4:¬} |
  607. {4:¬} |
  608. {4:~ }|
  609. |
  610. ]])
  611. feed_command('set nocursorline')
  612. screen:expect([[
  613. {5:^>-------.}abcd{5:*}{4:¬} |
  614. {5:>-------.}abcd{5:*}{4:¬} |
  615. {4:¬} |
  616. {4:~ }|
  617. :set nocursorline |
  618. ]])
  619. feed_command('set nowrap')
  620. feed('ALorem ipsum dolor sit amet<ESC>0')
  621. screen:expect([[
  622. {5:^>-------.}abcd{5:.}Lorem{4:>}|
  623. {5:>-------.}abcd{5:*}{4:¬} |
  624. {4:¬} |
  625. {4:~ }|
  626. |
  627. ]])
  628. feed_command('set cursorline')
  629. screen:expect([[
  630. {2:^>-------.}{1:abcd}{2:.}{1:Lorem}{3:>}|
  631. {5:>-------.}abcd{5:*}{4:¬} |
  632. {4:¬} |
  633. {4:~ }|
  634. :set cursorline |
  635. ]])
  636. feed('$')
  637. screen:expect([[
  638. {3:<}{1:r}{2:.}{1:sit}{2:.}{1:ame^t}{3:¬}{1: }|
  639. {4:<} |
  640. {4:<} |
  641. {4:~ }|
  642. :set cursorline |
  643. ]])
  644. feed('G')
  645. screen:expect([[
  646. {5:>-------.}abcd{5:.}Lorem{4:>}|
  647. {5:>-------.}abcd{5:*}{4:¬} |
  648. {3:^¬}{1: }|
  649. {4:~ }|
  650. :set cursorline |
  651. ]])
  652. end)
  653. it("'listchar' with wrap", function()
  654. screen:set_default_attr_ids({
  655. [0] = {bold=true, foreground=Screen.colors.Blue},
  656. })
  657. feed_command('set wrap')
  658. feed_command('set listchars=eol:¬,precedes:< list')
  659. feed('90ia<esc>')
  660. screen:expect([[
  661. {0:<}aaaaaaaaaaaaaaaaaaa|
  662. aaaaaaaaaaaaaaaaaaaa|
  663. aaaaaaaaaaaaaaaaaaaa|
  664. aaaaaaaaa^a{0:¬} |
  665. |
  666. ]])
  667. feed('0')
  668. screen:expect([[
  669. ^aaaaaaaaaaaaaaaaaaaa|
  670. aaaaaaaaaaaaaaaaaaaa|
  671. aaaaaaaaaaaaaaaaaaaa|
  672. aaaaaaaaaaaaaaaaaaaa|
  673. |
  674. ]])
  675. end)
  676. it("'listchar' in visual mode", function()
  677. screen:set_default_attr_ids({
  678. [1] = {background=Screen.colors.Grey90},
  679. [2] = {
  680. foreground=Screen.colors.Red,
  681. background=Screen.colors.Grey90,
  682. },
  683. [3] = {
  684. background=Screen.colors.Grey90,
  685. foreground=Screen.colors.Blue,
  686. bold=true,
  687. },
  688. [4] = {
  689. foreground=Screen.colors.Blue,
  690. bold=true,
  691. },
  692. [5] = {
  693. foreground=Screen.colors.Red,
  694. },
  695. [6] = {
  696. background=Screen.colors.LightGrey,
  697. },
  698. [7] = {
  699. background=Screen.colors.LightGrey,
  700. foreground=Screen.colors.Red,
  701. },
  702. [8] = {
  703. background=Screen.colors.LightGrey,
  704. foreground=Screen.colors.Blue,
  705. bold=true,
  706. },
  707. })
  708. feed_command('highlight clear ModeMsg')
  709. feed_command('highlight Whitespace guifg=#FF0000')
  710. feed_command('set cursorline')
  711. feed_command('set tabstop=8')
  712. feed_command('set nowrap')
  713. feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
  714. feed('i\t abcd <cr>\t abcd Lorem ipsum dolor sit amet<cr><esc>kkk0')
  715. screen:expect([[
  716. {2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }|
  717. {5:>-------.}abcd{5:.}Lorem{4:>}|
  718. {4:¬} |
  719. {4:~ }|
  720. |
  721. ]])
  722. feed('lllvj')
  723. screen:expect([[
  724. {5:>-------.}a{6:bcd}{7:*}{8:¬} |
  725. {7:>-------.}{6:a}^bcd{5:.}Lorem{4:>}|
  726. {4:¬} |
  727. {4:~ }|
  728. -- VISUAL -- |
  729. ]])
  730. feed('<esc>V')
  731. screen:expect([[
  732. {5:>-------.}abcd{5:*}{4:¬} |
  733. {7:>-------.}{6:a}^b{6:cd}{7:.}{6:Lorem}{4:>}|
  734. {4:¬} |
  735. {4:~ }|
  736. -- VISUAL LINE -- |
  737. ]])
  738. feed('<esc>$')
  739. screen:expect([[
  740. {4:<} |
  741. {3:<}{1:r}{2:.}{1:sit}{2:.}{1:ame^t}{3:¬}{1: }|
  742. {4:<} |
  743. {4:~ }|
  744. |
  745. ]])
  746. end)
  747. it("'cursorline' with :match", function()
  748. screen:set_default_attr_ids({
  749. [0] = {bold=true, foreground=Screen.colors.Blue},
  750. [1] = {background=Screen.colors.Grey90},
  751. [2] = {foreground=Screen.colors.Red},
  752. [3] = {foreground=Screen.colors.Green1},
  753. })
  754. feed_command('highlight clear ModeMsg')
  755. feed_command('highlight Whitespace guifg=#FF0000')
  756. feed_command('highlight Error guifg=#00FF00')
  757. feed_command('set nowrap')
  758. feed('ia \t bc \t <esc>')
  759. screen:expect([[
  760. a bc ^ |
  761. {0:~ }|
  762. {0:~ }|
  763. {0:~ }|
  764. |
  765. ]])
  766. feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
  767. screen:expect([[
  768. a{2:.>-----.}bc{2:*>---*^*}{0:¬} |
  769. {0:~ }|
  770. {0:~ }|
  771. {0:~ }|
  772. |
  773. ]])
  774. feed_command('match Error /\\s\\+$/')
  775. screen:expect([[
  776. a{2:.>-----.}bc{3:*>---*^*}{0:¬} |
  777. {0:~ }|
  778. {0:~ }|
  779. {0:~ }|
  780. |
  781. ]])
  782. end)
  783. end)
  784. describe('CursorLine highlight', function()
  785. before_each(clear)
  786. it('overridden by Error, ColorColumn if fg not set', function()
  787. local screen = Screen.new(50,5)
  788. screen:set_default_attr_ids({
  789. [1] = {foreground = Screen.colors.SlateBlue},
  790. [2] = {bold = true, foreground = Screen.colors.Brown},
  791. [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  792. [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90},
  793. [5] = {background = Screen.colors.Gray90},
  794. [6] = {bold = true, foreground = Screen.colors.Blue1},
  795. [7] = {background = Screen.colors.LightRed},
  796. })
  797. screen:attach()
  798. command('filetype on')
  799. command('syntax on')
  800. command('set cursorline ft=json')
  801. feed('i{<cr>"a" : abc // 10;<cr>}<cr><esc>')
  802. screen:expect([[
  803. {1:{} |
  804. "{2:a}" : {3:abc} {3:// 10;} |
  805. {1:}} |
  806. {5:^ }|
  807. |
  808. ]])
  809. command('set colorcolumn=3')
  810. feed('i <esc>')
  811. screen:expect([[
  812. {1:{} {7: } |
  813. "{2:a}{7:"} : {3:abc} {3:// 10;} |
  814. {1:}} {7: } |
  815. {5: ^ }{7: }{5: }|
  816. |
  817. ]])
  818. end)
  819. it("overridden by NonText in 'showbreak' characters", function()
  820. local screen = Screen.new(20,5)
  821. screen:set_default_attr_ids({
  822. [1] = {foreground = Screen.colors.Yellow, background = Screen.colors.Blue};
  823. [2] = {foreground = Screen.colors.Black, background = Screen.colors.White};
  824. [3] = {foreground = Screen.colors.Yellow, background = Screen.colors.White};
  825. [4] = {foreground = Screen.colors.Yellow};
  826. })
  827. screen:attach()
  828. feed_command('set wrap cursorline')
  829. feed_command('set showbreak=>>>')
  830. feed_command('highlight clear NonText')
  831. feed_command('highlight clear CursorLine')
  832. feed_command('highlight NonText guifg=Yellow guibg=Blue gui=NONE')
  833. feed_command('highlight CursorLine guifg=Black guibg=White gui=NONE')
  834. feed('30iø<esc>o<esc>30ia<esc>')
  835. screen:expect([[
  836. øøøøøøøøøøøøøøøøøøøø|
  837. {1:>>>}øøøøøøøøøø |
  838. {2:aaaaaaaaaaaaaaaaaaaa}|
  839. {1:>>>}{2:aaaaaaaaa^a }|
  840. |
  841. ]])
  842. feed('k')
  843. screen:expect([[
  844. {2:øøøøøøøøøøøøøøøøøøøø}|
  845. {1:>>>}{2:øøøøøøøøø^ø }|
  846. aaaaaaaaaaaaaaaaaaaa|
  847. {1:>>>}aaaaaaaaaa |
  848. |
  849. ]])
  850. feed_command('highlight NonText guibg=NONE')
  851. screen:expect([[
  852. {2:øøøøøøøøøøøøøøøøøøøø}|
  853. {3:>>>}{2:øøøøøøøøø^ø }|
  854. aaaaaaaaaaaaaaaaaaaa|
  855. {4:>>>}aaaaaaaaaa |
  856. |
  857. ]])
  858. feed_command('set nocursorline')
  859. screen:expect([[
  860. øøøøøøøøøøøøøøøøøøøø|
  861. {4:>>>}øøøøøøøøø^ø |
  862. aaaaaaaaaaaaaaaaaaaa|
  863. {4:>>>}aaaaaaaaaa |
  864. :set nocursorline |
  865. ]])
  866. end)
  867. it('always updated. vim-patch:8.1.0849', function()
  868. local screen = Screen.new(50,5)
  869. screen:set_default_attr_ids({
  870. [1] = {foreground = Screen.colors.SlateBlue},
  871. [2] = {bold = true, foreground = Screen.colors.Brown},
  872. [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  873. [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90},
  874. [5] = {background = Screen.colors.Gray90},
  875. [6] = {bold = true, foreground = Screen.colors.Blue1},
  876. [7] = {background = Screen.colors.LightRed},
  877. [8] = {foreground = Screen.colors.Brown},
  878. })
  879. screen:attach()
  880. command('set cursorline relativenumber')
  881. command('call setline(1, ["","1","2","3",""])')
  882. feed('Gy3k')
  883. screen:expect([[
  884. {2: 0 }{5:^1 }|
  885. {8: 1 }2 |
  886. {8: 2 }3 |
  887. {8: 3 } |
  888. 4 lines yanked |
  889. ]])
  890. feed('jj')
  891. screen:expect([[
  892. {8: 2 }1 |
  893. {8: 1 }2 |
  894. {2: 0 }{5:^3 }|
  895. {8: 1 } |
  896. 4 lines yanked |
  897. ]])
  898. end)
  899. it('with visual area. vim-patch:8.1.1001', function()
  900. local screen = Screen.new(50,5)
  901. screen:set_default_attr_ids({
  902. [1] = {foreground = Screen.colors.SlateBlue},
  903. [2] = {bold = true, foreground = Screen.colors.Brown},
  904. [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  905. [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90},
  906. [5] = {background = Screen.colors.Gray90},
  907. [6] = {bold = true, foreground = Screen.colors.Blue1},
  908. [7] = {background = Screen.colors.LightRed},
  909. [8] = {foreground = Screen.colors.Brown},
  910. [9] = {background = Screen.colors.LightGrey},
  911. [10] = {bold = true},
  912. })
  913. screen:attach()
  914. command('set cursorline')
  915. command('call setline(1, repeat(["abc"], 50))')
  916. feed('V<C-f>zbkkjk')
  917. screen:expect([[
  918. {9:abc} |
  919. ^a{9:bc} |
  920. abc |
  921. abc |
  922. {10:-- VISUAL LINE --} |
  923. ]])
  924. end)
  925. it('with split-windows in diff-mode', function()
  926. local screen = Screen.new(50,12)
  927. screen:set_default_attr_ids({
  928. [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  929. [2] = {bold = true, background = Screen.colors.Red},
  930. [3] = {background = Screen.colors.LightMagenta},
  931. [4] = {reverse = true},
  932. [5] = {background = Screen.colors.LightBlue},
  933. [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
  934. [7] = {background = Screen.colors.Red, foreground = Screen.colors.White},
  935. [8] = {bold = true, foreground = Screen.colors.Blue1},
  936. [9] = {bold = true, reverse = true},
  937. [10] = {bold = true},
  938. })
  939. screen:attach()
  940. command('hi CursorLine ctermbg=red ctermfg=white guibg=red guifg=white')
  941. command('set cursorline')
  942. feed('iline 1 some text<cr>line 2 more text<cr>extra line!<cr>extra line!<cr>last line ...<cr>')
  943. feed('<esc>gg')
  944. command('vsplit')
  945. command('enew')
  946. feed('iline 1 some text<cr>line 2 moRe text!<cr>extra line!<cr>extra line!<cr>extra line!<cr>last line ...<cr>')
  947. feed('<esc>gg')
  948. command('windo diffthis')
  949. screen:expect([[
  950. {1: }{7:line 1 some text }{4:│}{1: }{7:^line 1 some text }|
  951. {1: }{3:line 2 mo}{2:Re text!}{3: }{4:│}{1: }{3:line 2 mo}{2:re text}{3: }|
  952. {1: }{5:extra line! }{4:│}{1: }{6:----------------------}|
  953. {1: }extra line! {4:│}{1: }extra line! |
  954. {1: }extra line! {4:│}{1: }extra line! |
  955. {1: }last line ... {4:│}{1: }last line ... |
  956. {1: } {4:│}{1: } |
  957. {8:~ }{4:│}{8:~ }|
  958. {8:~ }{4:│}{8:~ }|
  959. {8:~ }{4:│}{8:~ }|
  960. {4:[No Name] [+] }{9:[No Name] [+] }|
  961. |
  962. ]])
  963. feed('jjjjj')
  964. screen:expect([[
  965. {1: }line 1 some text {4:│}{1: }line 1 some text |
  966. {1: }{3:line 2 mo}{2:Re text!}{3: }{4:│}{1: }{3:line 2 mo}{2:re text}{3: }|
  967. {1: }{5:extra line! }{4:│}{1: }{6:----------------------}|
  968. {1: }extra line! {4:│}{1: }extra line! |
  969. {1: }extra line! {4:│}{1: }extra line! |
  970. {1: }last line ... {4:│}{1: }last line ... |
  971. {1: }{7: }{4:│}{1: }{7:^ }|
  972. {8:~ }{4:│}{8:~ }|
  973. {8:~ }{4:│}{8:~ }|
  974. {8:~ }{4:│}{8:~ }|
  975. {4:[No Name] [+] }{9:[No Name] [+] }|
  976. |
  977. ]])
  978. -- CursorLine with fg=NONE is "low-priority".
  979. -- Rendered as underline in a diff-line. #9028
  980. command('hi CursorLine ctermbg=red ctermfg=NONE guibg=red guifg=NONE')
  981. feed('kkkk')
  982. screen:expect([[
  983. {1: }line 1 some text {4:│}{1: }line 1 some text |
  984. {1: }{11:line 2 mo}{12:Re text!}{11: }{4:│}{1: }{11:^line 2 mo}{12:re text}{11: }|
  985. {1: }{5:extra line! }{4:│}{1: }{6:----------------------}|
  986. {1: }extra line! {4:│}{1: }extra line! |
  987. {1: }extra line! {4:│}{1: }extra line! |
  988. {1: }last line ... {4:│}{1: }last line ... |
  989. {1: } {4:│}{1: } |
  990. {8:~ }{4:│}{8:~ }|
  991. {8:~ }{4:│}{8:~ }|
  992. {8:~ }{4:│}{8:~ }|
  993. {4:[No Name] [+] }{9:[No Name] [+] }|
  994. |
  995. ]], {
  996. [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray},
  997. [2] = {bold = true, background = Screen.colors.Red},
  998. [3] = {background = Screen.colors.LightMagenta},
  999. [4] = {reverse = true},
  1000. [5] = {background = Screen.colors.LightBlue},
  1001. [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1},
  1002. [7] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  1003. [8] = {bold = true, foreground = Screen.colors.Blue1},
  1004. [9] = {bold = true, reverse = true},
  1005. [10] = {bold = true},
  1006. [11] = {underline = true,
  1007. background = Screen.colors.LightMagenta},
  1008. [12] = {bold = true, underline = true,
  1009. background = Screen.colors.Red},
  1010. })
  1011. end)
  1012. end)
  1013. describe("MsgSeparator highlight and msgsep fillchar", function()
  1014. local screen
  1015. before_each(function()
  1016. clear()
  1017. screen = Screen.new(50,5)
  1018. screen:set_default_attr_ids({
  1019. [1] = {bold=true, foreground=Screen.colors.Blue},
  1020. [2] = {bold=true, reverse=true},
  1021. [3] = {bold = true, foreground = Screen.colors.SeaGreen4},
  1022. [4] = {background = Screen.colors.Cyan, bold = true, reverse = true},
  1023. [5] = {bold = true, background = Screen.colors.Magenta},
  1024. [6] = {background = Screen.colors.WebGray},
  1025. [7] = {background = Screen.colors.WebGray, bold = true, foreground = Screen.colors.SeaGreen4},
  1026. [8] = {foreground = Screen.colors.Grey0, background = Screen.colors.Gray60},
  1027. [9] = {foreground = Screen.colors.Grey40, background = Screen.colors.Gray60},
  1028. [10] = {foreground = tonumber('0x000019'), background = Screen.colors.Gray60},
  1029. [11] = {background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x666699')},
  1030. [12] = {background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x297d4e')},
  1031. [13] = {background = tonumber('0xff4cff'), bold = true, foreground = tonumber('0xb200ff')},
  1032. })
  1033. screen:attach()
  1034. end)
  1035. it("works", function()
  1036. -- defaults
  1037. feed_command("ls")
  1038. screen:expect([[
  1039. |
  1040. {2: }|
  1041. :ls |
  1042. 1 %a "[No Name]" line 1 |
  1043. {3:Press ENTER or type command to continue}^ |
  1044. ]])
  1045. feed('<cr>')
  1046. feed_command("set fillchars+=msgsep:-")
  1047. feed_command("ls")
  1048. screen:expect([[
  1049. |
  1050. {2:--------------------------------------------------}|
  1051. :ls |
  1052. 1 %a "[No Name]" line 1 |
  1053. {3:Press ENTER or type command to continue}^ |
  1054. ]])
  1055. -- linked to StatusLine per default
  1056. feed_command("hi StatusLine guibg=Cyan")
  1057. feed_command("ls")
  1058. screen:expect([[
  1059. |
  1060. {4:--------------------------------------------------}|
  1061. :ls |
  1062. 1 %a "[No Name]" line 1 |
  1063. {3:Press ENTER or type command to continue}^ |
  1064. ]])
  1065. -- but can be unlinked
  1066. feed_command("hi clear MsgSeparator")
  1067. feed_command("hi MsgSeparator guibg=Magenta gui=bold")
  1068. feed_command("ls")
  1069. screen:expect([[
  1070. |
  1071. {5:--------------------------------------------------}|
  1072. :ls |
  1073. 1 %a "[No Name]" line 1 |
  1074. {3:Press ENTER or type command to continue}^ |
  1075. ]])
  1076. -- when display doesn't contain msgsep, these options have no effect
  1077. feed_command("set display-=msgsep")
  1078. feed_command("ls")
  1079. screen:expect([[
  1080. {1:~ }|
  1081. {1:~ }|
  1082. :ls |
  1083. 1 %a "[No Name]" line 1 |
  1084. {3:Press ENTER or type command to continue}^ |
  1085. ]])
  1086. end)
  1087. it("and MsgArea", function()
  1088. feed_command("hi MsgArea guibg=Gray")
  1089. screen:expect{grid=[[
  1090. ^ |
  1091. {1:~ }|
  1092. {1:~ }|
  1093. {1:~ }|
  1094. {6: }|
  1095. ]]}
  1096. feed(":ls")
  1097. screen:expect{grid=[[
  1098. |
  1099. {1:~ }|
  1100. {1:~ }|
  1101. {1:~ }|
  1102. {6::ls^ }|
  1103. ]]}
  1104. feed(":<cr>")
  1105. screen:expect{grid=[[
  1106. |
  1107. {2: }|
  1108. {6::ls: }|
  1109. {6: 1 %a "[No Name]" line 1 }|
  1110. {7:Press ENTER or type command to continue}{6:^ }|
  1111. ]]}
  1112. -- support madness^Wblending of message "overlay"
  1113. feed_command("hi MsgArea blend=20")
  1114. feed_command("hi clear MsgSeparator")
  1115. feed_command("hi MsgSeparator blend=30 guibg=Magenta")
  1116. screen:expect{grid=[[
  1117. ^ |
  1118. {1:~ }|
  1119. {1:~ }|
  1120. {1:~ }|
  1121. {8::hi}{9: }{8:MsgSeparator}{9: }{8:blend=30}{9: }{8:guibg=Magenta}{9: }|
  1122. ]]}
  1123. feed(":ls")
  1124. screen:expect{grid=[[
  1125. |
  1126. {1:~ }|
  1127. {1:~ }|
  1128. {1:~ }|
  1129. {8::ls}{9:^ }|
  1130. ]]}
  1131. feed("<cr>")
  1132. screen:expect{grid=[[
  1133. |
  1134. {13:~ }|
  1135. {10::ls}{11: }|
  1136. {11:~ }{10:1}{11: }{10:%a}{11: }{10:"[No}{11: }{10:Name]"}{11: }{10:line}{11: }{10:1}{11: }|
  1137. {12:Press}{9: }{12:ENTER}{9: }{12:or}{9: }{12:type}{9: }{12:command}{9: }{12:to}{9: }{12:continue}{9:^ }|
  1138. ]]}
  1139. end)
  1140. end)
  1141. describe("'winhighlight' highlight", function()
  1142. local screen
  1143. before_each(function()
  1144. clear()
  1145. screen = Screen.new(20,8)
  1146. screen:attach()
  1147. screen:set_default_attr_ids({
  1148. [0] = {bold=true, foreground=Screen.colors.Blue},
  1149. [1] = {background = Screen.colors.DarkBlue},
  1150. [2] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Blue1},
  1151. [3] = {bold = true, reverse = true},
  1152. [4] = {reverse = true},
  1153. [5] = {background = Screen.colors.DarkGreen},
  1154. [6] = {background = Screen.colors.DarkGreen, bold = true, foreground = Screen.colors.Blue1},
  1155. [7] = {background = Screen.colors.DarkMagenta},
  1156. [8] = {background = Screen.colors.DarkMagenta, bold = true, foreground = Screen.colors.Blue1},
  1157. [9] = {foreground = Screen.colors.Brown},
  1158. [10] = {foreground = Screen.colors.Brown, background = Screen.colors.DarkBlue},
  1159. [11] = {background = Screen.colors.DarkBlue, bold = true, reverse = true},
  1160. [12] = {background = Screen.colors.DarkGreen, reverse = true},
  1161. [13] = {background = Screen.colors.Magenta4, reverse = true},
  1162. [14] = {background = Screen.colors.DarkBlue, reverse = true},
  1163. [15] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red},
  1164. [16] = {foreground = Screen.colors.Blue1},
  1165. [17] = {background = Screen.colors.LightRed},
  1166. [18] = {background = Screen.colors.Gray90},
  1167. [19] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray},
  1168. [20] = {background = Screen.colors.LightGrey, underline = true},
  1169. [21] = {bold = true},
  1170. [22] = {bold = true, foreground = Screen.colors.SeaGreen4},
  1171. [23] = {background = Screen.colors.LightMagenta},
  1172. [24] = {background = Screen.colors.WebGray},
  1173. [25] = {bold = true, foreground = Screen.colors.Green1},
  1174. [26] = {background = Screen.colors.Red},
  1175. [27] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Green1},
  1176. [28] = {bold = true, foreground = Screen.colors.Brown},
  1177. })
  1178. command("hi Background1 guibg=DarkBlue")
  1179. command("hi Background2 guibg=DarkGreen")
  1180. end)
  1181. it('works for background color', function()
  1182. insert("aa")
  1183. command("split")
  1184. command("set winhl=Normal:Background1")
  1185. screen:expect([[
  1186. {1:a^a }|
  1187. {2:~ }|
  1188. {2:~ }|
  1189. {3:[No Name] [+] }|
  1190. aa |
  1191. {0:~ }|
  1192. {4:[No Name] [+] }|
  1193. |
  1194. ]])
  1195. command("enew")
  1196. screen:expect([[
  1197. {1:^ }|
  1198. {2:~ }|
  1199. {2:~ }|
  1200. {3:[No Name] }|
  1201. aa |
  1202. {0:~ }|
  1203. {4:[No Name] [+] }|
  1204. |
  1205. ]])
  1206. end)
  1207. it('handles invalid values', function()
  1208. command("set winhl=Normal:Background1")
  1209. screen:expect([[
  1210. {1:^ }|
  1211. {2:~ }|
  1212. {2:~ }|
  1213. {2:~ }|
  1214. {2:~ }|
  1215. {2:~ }|
  1216. {2:~ }|
  1217. |
  1218. ]])
  1219. eq('Vim(set):E474: Invalid argument: winhl=xxx:yyy',
  1220. exc_exec("set winhl=xxx:yyy"))
  1221. eq('Normal:Background1', eval('&winhl'))
  1222. screen:expect{grid=[[
  1223. {1:^ }|
  1224. {2:~ }|
  1225. {2:~ }|
  1226. {2:~ }|
  1227. {2:~ }|
  1228. {2:~ }|
  1229. {2:~ }|
  1230. |
  1231. ]], unchanged=true}
  1232. end)
  1233. it('works local to the buffer', function()
  1234. insert("aa")
  1235. command("split")
  1236. command("setlocal winhl=Normal:Background1")
  1237. screen:expect([[
  1238. {1:a^a }|
  1239. {2:~ }|
  1240. {2:~ }|
  1241. {3:[No Name] [+] }|
  1242. aa |
  1243. {0:~ }|
  1244. {4:[No Name] [+] }|
  1245. |
  1246. ]])
  1247. command("enew")
  1248. screen:expect([[
  1249. ^ |
  1250. {0:~ }|
  1251. {0:~ }|
  1252. {3:[No Name] }|
  1253. aa |
  1254. {0:~ }|
  1255. {4:[No Name] [+] }|
  1256. |
  1257. ]])
  1258. command("bnext")
  1259. screen:expect([[
  1260. {1:^aa }|
  1261. {2:~ }|
  1262. {2:~ }|
  1263. {3:[No Name] [+] }|
  1264. aa |
  1265. {0:~ }|
  1266. {4:[No Name] [+] }|
  1267. |
  1268. ]])
  1269. end)
  1270. it('for inactive window background works', function()
  1271. command("set winhl=Normal:Background1,NormalNC:Background2")
  1272. -- tests global value is copied across split
  1273. command("split")
  1274. screen:expect([[
  1275. {1:^ }|
  1276. {2:~ }|
  1277. {2:~ }|
  1278. {3:[No Name] }|
  1279. {5: }|
  1280. {6:~ }|
  1281. {4:[No Name] }|
  1282. |
  1283. ]])
  1284. feed("<c-w><c-w>")
  1285. screen:expect([[
  1286. {5: }|
  1287. {6:~ }|
  1288. {6:~ }|
  1289. {4:[No Name] }|
  1290. {1:^ }|
  1291. {2:~ }|
  1292. {3:[No Name] }|
  1293. |
  1294. ]])
  1295. feed("<c-w><c-w>")
  1296. screen:expect([[
  1297. {1:^ }|
  1298. {2:~ }|
  1299. {2:~ }|
  1300. {3:[No Name] }|
  1301. {5: }|
  1302. {6:~ }|
  1303. {4:[No Name] }|
  1304. |
  1305. ]])
  1306. end)
  1307. it('works with NormalNC', function()
  1308. command("hi NormalNC guibg=DarkMagenta")
  1309. -- tests global value is copied across split
  1310. command("split")
  1311. screen:expect([[
  1312. ^ |
  1313. {0:~ }|
  1314. {0:~ }|
  1315. {3:[No Name] }|
  1316. {7: }|
  1317. {8:~ }|
  1318. {4:[No Name] }|
  1319. |
  1320. ]])
  1321. command("wincmd w")
  1322. screen:expect([[
  1323. {7: }|
  1324. {8:~ }|
  1325. {8:~ }|
  1326. {4:[No Name] }|
  1327. ^ |
  1328. {0:~ }|
  1329. {3:[No Name] }|
  1330. |
  1331. ]])
  1332. -- winbg=Normal:... overrides global NormalNC
  1333. command("set winhl=Normal:Background1")
  1334. screen:expect([[
  1335. {7: }|
  1336. {8:~ }|
  1337. {8:~ }|
  1338. {4:[No Name] }|
  1339. {1:^ }|
  1340. {2:~ }|
  1341. {3:[No Name] }|
  1342. |
  1343. ]])
  1344. command("wincmd w")
  1345. screen:expect([[
  1346. ^ |
  1347. {0:~ }|
  1348. {0:~ }|
  1349. {3:[No Name] }|
  1350. {1: }|
  1351. {2:~ }|
  1352. {4:[No Name] }|
  1353. |
  1354. ]])
  1355. command("wincmd w")
  1356. command("set winhl=Normal:Background1,NormalNC:Background2")
  1357. screen:expect([[
  1358. {7: }|
  1359. {8:~ }|
  1360. {8:~ }|
  1361. {4:[No Name] }|
  1362. {1:^ }|
  1363. {2:~ }|
  1364. {3:[No Name] }|
  1365. |
  1366. ]])
  1367. command("wincmd w")
  1368. screen:expect([[
  1369. ^ |
  1370. {0:~ }|
  1371. {0:~ }|
  1372. {3:[No Name] }|
  1373. {5: }|
  1374. {6:~ }|
  1375. {4:[No Name] }|
  1376. |
  1377. ]])
  1378. end)
  1379. it('background applies also to non-text', function()
  1380. command('set sidescroll=0')
  1381. insert('Lorem ipsum dolor sit amet ')
  1382. command('set shiftwidth=2')
  1383. feed('>>')
  1384. command('set number')
  1385. command('set breakindent')
  1386. command('set briopt=shift:5,min:0')
  1387. command('set list')
  1388. command('set showbreak=↪')
  1389. screen:expect([[
  1390. {9: 1 } ^Lorem ipsum do|
  1391. {9: } {0:↪}lor sit |
  1392. {9: } {0:↪}amet{0:-} |
  1393. {0:~ }|
  1394. {0:~ }|
  1395. {0:~ }|
  1396. {0:~ }|
  1397. |
  1398. ]])
  1399. command('set winhl=Normal:Background1')
  1400. screen:expect([[
  1401. {10: 1 }{1: ^Lorem ipsum do}|
  1402. {10: }{1: }{2:↪}{1:lor sit }|
  1403. {10: }{1: }{2:↪}{1:amet}{2:-}{1: }|
  1404. {2:~ }|
  1405. {2:~ }|
  1406. {2:~ }|
  1407. {2:~ }|
  1408. |
  1409. ]])
  1410. command('set nowrap')
  1411. command('set listchars+=extends:❯,precedes:❮')
  1412. feed('3w')
  1413. screen:expect([[
  1414. {10: 1 }{2:❮}{1: dolor ^sit ame}{2:❯}|
  1415. {2:~ }|
  1416. {2:~ }|
  1417. {2:~ }|
  1418. {2:~ }|
  1419. {2:~ }|
  1420. {2:~ }|
  1421. |
  1422. ]])
  1423. end)
  1424. it("background doesn't override syntax background", function()
  1425. command('syntax on')
  1426. command('syntax keyword Foobar foobar')
  1427. command('syntax keyword Article the')
  1428. command('hi Foobar guibg=#FF0000')
  1429. command('hi Article guifg=#00FF00 gui=bold')
  1430. insert('the foobar was foobar')
  1431. screen:expect([[
  1432. {25:the} {26:foobar} was {26:fooba}|
  1433. {26:^r} |
  1434. {0:~ }|
  1435. {0:~ }|
  1436. {0:~ }|
  1437. {0:~ }|
  1438. {0:~ }|
  1439. |
  1440. ]])
  1441. -- winhl=Normal:Group with background doesn't override syntax background,
  1442. -- but does combine with syntax foreground.
  1443. command('set winhl=Normal:Background1')
  1444. screen:expect([[
  1445. {27:the}{1: }{26:foobar}{1: was }{26:fooba}|
  1446. {26:^r}{1: }|
  1447. {2:~ }|
  1448. {2:~ }|
  1449. {2:~ }|
  1450. {2:~ }|
  1451. {2:~ }|
  1452. |
  1453. ]])
  1454. end)
  1455. it('can override NonText, Conceal and EndOfBuffer', function()
  1456. curbufmeths.set_lines(0,-1,true, {"raa\000"})
  1457. command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})')
  1458. command('set cole=2 cocu=nvic')
  1459. command('split')
  1460. command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})')
  1461. command('set winhl=SpecialKey:ErrorMsg,EndOfBuffer:Background1,'
  1462. ..'Conceal:Background2')
  1463. screen:expect([[
  1464. ^r{5:#}a{15:^@} |
  1465. {1:~ }|
  1466. {1:~ }|
  1467. {3:[No Name] [+] }|
  1468. r{19:#}a{16:^@} |
  1469. {0:~ }|
  1470. {4:[No Name] [+] }|
  1471. |
  1472. ]])
  1473. end)
  1474. it('can override LineNr, CursorColumn and ColorColumn', function()
  1475. insert('very text\nmore text')
  1476. command('set number')
  1477. command('set colorcolumn=2')
  1478. command('set cursorcolumn')
  1479. feed('k')
  1480. command('split')
  1481. command('set winhl=LineNr:Background1,CursorColumn:Background2,'
  1482. ..'ColorColumn:ErrorMsg')
  1483. screen:expect([[
  1484. {1: 1 }v{15:e}ry tex^t |
  1485. {1: 2 }m{15:o}re tex{5:t} |
  1486. {0:~ }|
  1487. {3:[No Name] [+] }|
  1488. {9: 1 }v{17:e}ry text |
  1489. {9: 2 }m{17:o}re tex{18:t} |
  1490. {4:[No Name] [+] }|
  1491. |
  1492. ]])
  1493. end)
  1494. it('can override Tabline', function()
  1495. command('tabnew')
  1496. command('set winhl=TabLine:Background1,TabLineSel:ErrorMsg')
  1497. screen:expect([[
  1498. {20: No Name] }{15: No Name]}{20:X}|
  1499. ^ |
  1500. {0:~ }|
  1501. {0:~ }|
  1502. {0:~ }|
  1503. {0:~ }|
  1504. {0:~ }|
  1505. |
  1506. ]])
  1507. command("tabnext")
  1508. screen:expect([[
  1509. {21: No Name] }{1: No Name]}{20:X}|
  1510. ^ |
  1511. {0:~ }|
  1512. {0:~ }|
  1513. {0:~ }|
  1514. {0:~ }|
  1515. {0:~ }|
  1516. |
  1517. ]])
  1518. end)
  1519. it('can override popupmenu', function()
  1520. insert('word wording wordy')
  1521. command('split')
  1522. command('set winhl=Pmenu:Background1,PmenuSel:Background2,'
  1523. ..'PmenuSbar:ErrorMsg,PmenuThumb:Normal')
  1524. screen:expect([[
  1525. word wording word^y |
  1526. {0:~ }|
  1527. {0:~ }|
  1528. {3:[No Name] [+] }|
  1529. word wording wordy |
  1530. {0:~ }|
  1531. {4:[No Name] [+] }|
  1532. |
  1533. ]])
  1534. feed('oword<c-x><c-p>')
  1535. screen:expect([[
  1536. word wording wordy |
  1537. wordy^ |
  1538. {1:word }{0: }|
  1539. {1:wording }{3: }|
  1540. {5:wordy }rdy |
  1541. wordy |
  1542. {4:[No Name] [+] }|
  1543. {21:-- }{22:match 1 of 3} |
  1544. ]])
  1545. feed('<esc>u<c-w><c-w>oword<c-x><c-p>')
  1546. screen:expect([[
  1547. word wording wordy |
  1548. wordy |
  1549. {23:word }{0: }|
  1550. {23:wording }{4: }|
  1551. {24:wordy }rdy |
  1552. wordy^ |
  1553. {3:[No Name] [+] }|
  1554. {21:-- }{22:match 1 of 3} |
  1555. ]])
  1556. end)
  1557. it('can override CursorLine and CursorLineNr', function()
  1558. -- CursorLine used to be parsed as CursorLineNr, because strncmp
  1559. command('set cursorline number')
  1560. command('split')
  1561. command('set winhl=CursorLine:Background1')
  1562. screen:expect{grid=[[
  1563. {28: 1 }{1:^ }|
  1564. {0:~ }|
  1565. {0:~ }|
  1566. {3:[No Name] }|
  1567. {28: 1 }{18: }|
  1568. {0:~ }|
  1569. {4:[No Name] }|
  1570. |
  1571. ]]}
  1572. command('set winhl=CursorLineNr:Background2,CursorLine:Background1')
  1573. screen:expect{grid=[[
  1574. {5: 1 }{1:^ }|
  1575. {0:~ }|
  1576. {0:~ }|
  1577. {3:[No Name] }|
  1578. {28: 1 }{18: }|
  1579. {0:~ }|
  1580. {4:[No Name] }|
  1581. |
  1582. ]]}
  1583. feed('<c-w>w')
  1584. screen:expect{grid=[[
  1585. {5: 1 }{1: }|
  1586. {0:~ }|
  1587. {0:~ }|
  1588. {4:[No Name] }|
  1589. {28: 1 }{18:^ }|
  1590. {0:~ }|
  1591. {3:[No Name] }|
  1592. |
  1593. ]]}
  1594. end)
  1595. end)