068_text_formatting_spec.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local feed = helpers.feed
  3. local clear = helpers.clear
  4. local insert = helpers.insert
  5. local feed_command = helpers.feed_command
  6. local expect = helpers.expect
  7. describe('text formatting', function()
  8. setup(clear)
  9. -- luacheck: ignore 613 (Trailing whitespace in a string)
  10. it('is working', function()
  11. -- The control character <C-A> (byte \x01) needs to be put in the buffer
  12. -- directly. But the insert function sends the text to nvim in insert
  13. -- mode so it has to be escaped with <C-V>.
  14. insert([[
  15. Results of test68:
  16. {
  17. }
  18. {
  19. a b
  20. a
  21. }
  22. {
  23. a 
  24. }
  25. {
  26. a b
  27. #a b
  28. }
  29. {
  30. 1 a
  31. # 1 a
  32. }
  33. {
  34. x a
  35. b
  36. c
  37. }
  38. {
  39. # 1 a b
  40. }
  41. {
  42. # x
  43. # a b
  44. }
  45. {
  46. 1aa
  47. 2bb
  48. }
  49. /* abc def ghi jkl
  50. * mno pqr stu
  51. */
  52. # 1 xxxxx
  53. ]])
  54. feed_command('/^{/+1')
  55. feed_command('set noai tw=2 fo=t')
  56. feed('gRa b<esc>')
  57. feed_command('/^{/+1')
  58. feed_command('set ai tw=2 fo=tw')
  59. feed('gqgqjjllab<esc>')
  60. feed_command('/^{/+1')
  61. feed_command('set tw=3 fo=t')
  62. feed('gqgqo<cr>')
  63. feed('a <C-V><C-A><esc><esc>')
  64. feed_command('/^{/+1')
  65. feed_command('set tw=2 fo=tcq1 comments=:#')
  66. feed('gqgqjgqgqo<cr>')
  67. feed('a b<cr>')
  68. feed('#a b<esc>')
  69. feed_command('/^{/+1')
  70. feed_command('set tw=5 fo=tcn comments=:#')
  71. feed('A b<esc>jA b<esc>')
  72. feed_command('/^{/+3')
  73. feed_command('set tw=5 fo=t2a si')
  74. feed('i <esc>A_<esc>')
  75. feed_command('/^{/+1')
  76. feed_command('set tw=5 fo=qn comments=:#')
  77. feed('gwap<cr>')
  78. feed_command('/^{/+1')
  79. feed_command('set tw=5 fo=q2 comments=:#')
  80. feed('gwap<cr>')
  81. feed_command('/^{/+2')
  82. feed_command('set tw& fo=a')
  83. feed('I^^<esc><esc>')
  84. feed_command('/mno pqr/')
  85. feed_command('setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/')
  86. feed('A vwx yz<esc>')
  87. feed_command('/^#/')
  88. feed_command('setl tw=12 fo=tqnc comments=:#')
  89. feed('A foobar<esc>')
  90. -- Assert buffer contents.
  91. expect([[
  92. Results of test68:
  93. {
  94. a
  95. b
  96. }
  97. {
  98. a
  99. b
  100. a
  101. b
  102. }
  103. {
  104. a
  105. 
  106. a
  107. 
  108. }
  109. {
  110. a b
  111. #a b
  112. a b
  113. #a b
  114. }
  115. {
  116. 1 a
  117. b
  118. # 1 a
  119. # b
  120. }
  121. {
  122. x a
  123. b_
  124. c
  125. }
  126. {
  127. # 1 a
  128. # b
  129. }
  130. {
  131. # x a
  132. # b
  133. }
  134. { 1aa ^^2bb }
  135. /* abc def ghi jkl
  136. * mno pqr stu
  137. * vwx yz
  138. */
  139. # 1 xxxxx
  140. # foobar
  141. ]])
  142. end)
  143. end)