robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1local n =require ( 'test.functional.testnvim' )() 2local t =require ( 'test.testutil' ) 3 4local describe , it , setup =t . describe , t . it , t . setup 5local feed =n . feed 6local clear =n . clear 7local insert =n . insert 8local feed_command =n . feed_command 9local expect =n . expect 10 11describe ( 'text formatting' , function () 12setup ( clear ) 13 14-- luacheck: ignore 613 (Trailing whitespace in a string) 15it ( 'is working' , function () 16-- The control character <C-A> (byte \x01) needs to be put in the buffer 17-- directly. But the insert function sends the text to nvim in insert 18-- mode so it has to be escaped with <C-V>. 19insert ( [[ 20Results of test68: 21 22 23{ 24 25 26} 27 28 29{ 30a b 31 32a 33} 34 35 36{ 37a 38} 39 40 41{ 42a b 43#a b 44} 45 46 47{ 481 a 49# 1 a 50} 51 52 53{ 54 55x a 56b 57c 58 59} 60 61 62{ 63# 1 a b 64} 65 66 67{ 68# x 69# a b 70} 71 72 73{ 741aa 752bb 76} 77 78 79/* abc def ghi jkl 80* mno pqr stu 81*/ 82 83 84# 1 xxxxx 85]] ) 86 87feed_command ( '/^{/+1' ) 88feed_command ( 'set noai tw=2 fo=t' ) 89feed ( 'gRa b<esc>' ) 90 91feed_command ( '/^{/+1' ) 92feed_command ( 'set ai tw=2 fo=tw' ) 93feed ( 'gqgqjjllab<esc>' ) 94 95feed_command ( '/^{/+1' ) 96feed_command ( 'set tw=3 fo=t' ) 97feed ( 'gqgqo<cr>' ) 98feed ( 'a <C-V><C-A><esc><esc>' ) 99 100feed_command ( '/^{/+1' ) 101feed_command ( 'set tw=2 fo=tcq1 comments=:#' ) 102feed ( 'gqgqjgqgqo<cr>' ) 103feed ( 'a b<cr>' ) 104feed ( '#a b<esc>' ) 105 106feed_command ( '/^{/+1' ) 107feed_command ( 'set tw=5 fo=tcn comments=:#' ) 108feed ( 'A b<esc>jA b<esc>' ) 109 110feed_command ( '/^{/+3' ) 111feed_command ( 'set tw=5 fo=t2a si' ) 112feed ( 'i <esc>A_<esc>' ) 113 114feed_command ( '/^{/+1' ) 115feed_command ( 'set tw=5 fo=qn comments=:#' ) 116feed ( 'gwap<cr>' ) 117 118feed_command ( '/^{/+1' ) 119feed_command ( 'set tw=5 fo=q2 comments=:#' ) 120feed ( 'gwap<cr>' ) 121 122feed_command ( '/^{/+2' ) 123feed_command ( 'set tw& fo=a' ) 124feed ( 'I^^<esc><esc>' ) 125 126feed_command ( '/mno pqr/' ) 127feed_command ( 'setl tw=20 fo=an12wcq comments=s1:/*,mb:*,ex:*/' ) 128feed ( 'A vwx yz<esc>' ) 129 130feed_command ( '/^#/' ) 131feed_command ( 'setl tw=12 fo=tqnc comments=:#' ) 132feed ( 'A foobar<esc>' ) 133 134-- Assert buffer contents. 135expect ( [[ 136Results of test68: 137 138 139{ 140a 141b 142} 143 144 145{ 146a 147b 148 149a 150b 151} 152 153 154{ 155a 156157 158 a 159160 } 161 162 163{ 164a b 165#a b 166 167a b 168#a b 169} 170 171 172{ 1731 a 174b 175# 1 a 176# b 177} 178 179 180{ 181 182x a 183b_ 184c 185 186} 187 188 189{ 190# 1 a 191# b 192} 193 194 195{ 196# x a 197# b 198} 199 200 201{ 1aa ^^2bb } 202 203 204/* abc def ghi jkl 205* mno pqr stu 206* vwx yz 207*/ 208 209 210# 1 xxxxx 211# foobar 212]] ) 213end ) 214end )