neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

068_text_formatting_spec.lua (2792B)


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