robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
aa1d8a2702
master
1local t =require ( 'test.testutil' ) 2local n =require ( 'test.functional.testnvim' )() 3 4local describe , it , before_each =t . describe , t . it , t . before_each 5local command =n . command 6local api =n . api 7local fn =n . fn 8local eval =n . eval 9local feed =n . feed 10local clear =n . clear 11local eq =t . eq 12local neq =t . neq 13 14describe ( 'optwin.lua' , function () 15before_each ( clear ) 16 17it ( ':options shows options UI' , function () 18command 'options' 19 20command '/^ 1' 21local lnum =fn . line ( '.' ) 22feed ( '<CR>' ) 23neq ( lnum , fn . line ( '.' )) 24 25n . add_builddir_to_rtp () 26command '/^startofline' 27local win =api . nvim_get_current_win () 28feed ( '<CR>' ) 29neq ( win , api . nvim_get_current_win ()) 30eq ( 'help' , eval ( '&filetype' )) 31api . nvim_win_close ( 0 , true ) 32eq ( win , api . nvim_get_current_win ()) 33 34command '/^ \t' 35local opt_value =eval ( '&startofline' ) 36local line =api . nvim_get_current_line () 37feed ( '<CR>' ) 38neq ( opt_value , eval ( '&startofline' )) 39neq ( line , api . nvim_get_current_line ()) 40 41command ( 'set startofline!' ) 42neq ( line , api . nvim_get_current_line ()) 43feed ( '<space>' ) 44eq ( line , api . nvim_get_current_line ()) 45 46command 'wincmd j' 47command 'wincmd k' 48command '/^number' 49command '/^ \t' 50line =api . nvim_get_current_line () 51feed ( '<CR>' ) 52neq ( line , api . nvim_get_current_line ()) 53command 'wincmd o' 54feed ( '<CR>' ) 55eq ( line , api . nvim_get_current_line ()) 56feed ( '<CR>' ) 57neq ( line , api . nvim_get_current_line ()) 58end ) 59 60it ( ':options shows all options' , function () 61local ignore ={ 62-- These options are removed/unused/deprecated 63'compatible' , 64'paste' , 65'highlight' , 66'terse' , 67'aleph' , 68'encoding' , 69'termencoding' , 70'maxcombine' , 71'secure' , 72'prompt' , 73'edcompatible' , 74'gdefault' , 75'guioptions' , 76'guitablabel' , 77'guitabtooltip' , 78'insertmode' , 79'magic' , 80'mouseshape' , 81'imcmdline' , 82'imdisable' , 83'pastetoggle' , 84'langnoremap' , 85'opendevice' , 86'remap' , 87'hkmap' , 88'hkmapp' , 89 90-- These options are read-only 91'channel' , 92} 93 94command 'options' 95 96local options =ignore 97for _ , line in ipairs ( api . nvim_buf_get_lines ( 0 , 0 , - 1 , true )) do 98if line : match ( '^[a-z]' ) then 99table . insert ( options , line : match ( '^[a-z]+' )) 100end 101end 102 103eq ( fn . sort ( vim . tbl_keys ( api . nvim_get_all_options_info ())), fn . sort ( options )) 104end ) 105end )