quickfix_spec.lua 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. local n = require('test.functional.testnvim')()
  2. local Screen = require('test.functional.ui.screen')
  3. local clear, feed, api = n.clear, n.feed, n.api
  4. local insert, command = n.insert, n.command
  5. describe('quickfix selection highlight', function()
  6. local screen
  7. before_each(function()
  8. clear()
  9. screen = Screen.new(25, 10)
  10. screen:set_default_attr_ids({
  11. [1] = { bold = true, foreground = Screen.colors.Blue },
  12. [2] = { reverse = true },
  13. [3] = { foreground = Screen.colors.Brown },
  14. [4] = { bold = true, reverse = true },
  15. [5] = { background = Screen.colors.Green },
  16. [6] = { foreground = Screen.colors.Brown, background = Screen.colors.Green },
  17. [7] = { background = Screen.colors.Red },
  18. [8] = { foreground = Screen.colors.Brown, background = Screen.colors.Red },
  19. [9] = { background = Screen.colors.Fuchsia },
  20. [10] = { foreground = Screen.colors.Red, background = Screen.colors.Fuchsia },
  21. [11] = { foreground = Screen.colors.Red },
  22. [12] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia },
  23. })
  24. api.nvim_set_option_value('errorformat', '%m %l', {})
  25. command('syntax on')
  26. command('highlight Search guibg=Green')
  27. insert([[
  28. Line 1
  29. Line 2
  30. Line 3
  31. Line 4
  32. Line 5
  33. ]])
  34. command('cad')
  35. feed('gg')
  36. screen:expect([[
  37. ^Line 1 |
  38. Line 2 |
  39. Line 3 |
  40. Line 4 |
  41. Line 5 |
  42. |
  43. {1:~ }|*3
  44. |
  45. ]])
  46. end)
  47. it('using default Search highlight group', function()
  48. command('copen')
  49. screen:expect([[
  50. Line 1 |
  51. {2:[No Name] [+] }|
  52. {5:^|}{6:1}{5:| Line }|
  53. |{3:2}| Line |
  54. |{3:3}| Line |
  55. |{3:4}| Line |
  56. |{3:5}| Line |
  57. || |
  58. {4:[Quickfix List] }|
  59. |
  60. ]])
  61. command('cnext')
  62. screen:expect([[
  63. Line 1 |
  64. {2:[No Name] [+] }|
  65. |{3:1}| Line |
  66. {5:^|}{6:2}{5:| Line }|
  67. |{3:3}| Line |
  68. |{3:4}| Line |
  69. |{3:5}| Line |
  70. || |
  71. {4:[Quickfix List] }|
  72. |
  73. ]])
  74. end)
  75. it('using QuickFixLine highlight group', function()
  76. command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
  77. command('copen')
  78. screen:expect([[
  79. Line 1 |
  80. {2:[No Name] [+] }|
  81. {7:^|}{8:1}{7:| Line }|
  82. |{3:2}| Line |
  83. |{3:3}| Line |
  84. |{3:4}| Line |
  85. |{3:5}| Line |
  86. || |
  87. {4:[Quickfix List] }|
  88. |
  89. ]])
  90. command('cnext')
  91. screen:expect([[
  92. Line 1 |
  93. {2:[No Name] [+] }|
  94. |{3:1}| Line |
  95. {7:^|}{8:2}{7:| Line }|
  96. |{3:3}| Line |
  97. |{3:4}| Line |
  98. |{3:5}| Line |
  99. || |
  100. {4:[Quickfix List] }|
  101. |
  102. ]])
  103. end)
  104. it('combines with CursorLine', function()
  105. command('set cursorline')
  106. command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE')
  107. command('highlight CursorLine guibg=Fuchsia')
  108. command('copen')
  109. screen:expect([[
  110. {9:Line 1 }|
  111. {2:[No Name] [+] }|
  112. {10:^|1| Line }|
  113. |{3:2}| Line |
  114. |{3:3}| Line |
  115. |{3:4}| Line |
  116. |{3:5}| Line |
  117. || |
  118. {4:[Quickfix List] }|
  119. |
  120. ]])
  121. feed('j')
  122. screen:expect([[
  123. {9:Line 1 }|
  124. {2:[No Name] [+] }|
  125. {11:|1| Line }|
  126. {9:^|}{12:2}{9:| Line }|
  127. |{3:3}| Line |
  128. |{3:4}| Line |
  129. |{3:5}| Line |
  130. || |
  131. {4:[Quickfix List] }|
  132. |
  133. ]])
  134. end)
  135. it('QuickFixLine background takes precedence over CursorLine', function()
  136. command('set cursorline')
  137. command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
  138. command('highlight CursorLine guibg=Fuchsia')
  139. command('copen')
  140. screen:expect([[
  141. {9:Line 1 }|
  142. {2:[No Name] [+] }|
  143. {7:^|}{8:1}{7:| Line }|
  144. |{3:2}| Line |
  145. |{3:3}| Line |
  146. |{3:4}| Line |
  147. |{3:5}| Line |
  148. || |
  149. {4:[Quickfix List] }|
  150. |
  151. ]])
  152. feed('j')
  153. screen:expect([[
  154. {9:Line 1 }|
  155. {2:[No Name] [+] }|
  156. {7:|}{8:1}{7:| Line }|
  157. {9:^|}{12:2}{9:| Line }|
  158. |{3:3}| Line |
  159. |{3:4}| Line |
  160. |{3:5}| Line |
  161. || |
  162. {4:[Quickfix List] }|
  163. |
  164. ]])
  165. end)
  166. end)