robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Test for autocommand that changes current buffer on BufEnter event. 2-- Check if modelines are interpreted for the correct buffer. 3 4local n =require ( 'test.functional.testnvim' )() 5local t =require ( 'test.testutil' ) 6 7local describe , it , setup , teardown =t . describe , t . it , t . setup , t . teardown 8local clear , feed , insert =n . clear , n . feed , n . insert 9local feed_command , expect =n . feed_command , n . expect 10 11describe ( 'BufEnter with modelines' , function () 12setup ( clear ) 13 14it ( 'is working' , function () 15insert ( [[ 16startstart 17start of test file Xxx 18vim: set noai : 19this is a test 20this is a test 21this is a test 22this is a test 23end of test file Xxx]] ) 24 25feed_command ( 'au BufEnter Xxx brew' ) 26 27-- Write test file Xxx 28feed_command ( '/start of' ) 29feed_command ( '.,/end of/w! Xxx' ) 30feed_command ( 'set ai modeline modelines=3' ) 31 32-- Split to Xxx, autocmd will do :brew 33feed_command ( 'sp Xxx' ) 34 35-- Append text with autoindent to this file 36feed ( 'G?this is a<CR>' ) 37feed ( 'othis should be auto-indented<Esc>' ) 38 39-- Go to Xxx, no autocmd anymore 40feed_command ( 'au! BufEnter Xxx' ) 41feed_command ( 'buf Xxx' ) 42 43-- Append text without autoindent to Xxx 44feed ( 'G?this is a<CR>' ) 45feed ( 'othis should be in column 1<Esc>' ) 46feed_command ( 'wq' ) 47 48-- Include Xxx in the current file 49feed ( 'G:r Xxx<CR>' ) 50 51-- Vim issue #57 do not move cursor on <c-o> when autoindent is set 52feed_command ( 'set fo+=r' ) 53feed ( 'G' ) 54feed ( 'o# abcdef<Esc>2hi<CR><c-o>d0<Esc>' ) 55feed ( 'o# abcdef<Esc>2hi<c-o>d0<Esc>' ) 56 57expect ( [[ 58startstart 59start of test file Xxx 60vim: set noai : 61this is a test 62this is a test 63this is a test 64this is a test 65this should be auto-indented 66end of test file Xxx 67start of test file Xxx 68vim: set noai : 69this is a test 70this is a test 71this is a test 72this is a test 73this should be in column 1 74end of test file Xxx 75# abc 76def 77def]] ) 78end ) 79 80teardown ( function () 81os . remove ( 'Xxx' ) 82end ) 83end )