blob: 5be06cea12fd9bf9969c12e7d30f7701853184f0 [file] [log] [blame]
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01001" Script to generate testdir/opt_test.vim from option.c
2
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01003set cpo=&vim
Bram Moolenaar5b3af142017-02-27 22:59:40 +01004
5" Only do this when build with the +eval feature.
6if 1
7
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01008set nomore
9
Milly40c6bab2024-10-04 20:41:14 +020010const K_KENTER = -16715
11
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010012" The terminal size is restored at the end.
13" Clear out t_WS, we don't want to resize the actual terminal.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010014let script = [
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010015 \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +000016 \ '" Used by test_options.vim.',
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010017 \ '',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010018 \ 'let save_columns = &columns',
19 \ 'let save_lines = &lines',
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010020 \ 'set t_WS=',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010021 \ ]
22
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010023/#define p_term
24let end = line('.')
25
Bram Moolenaar17471e82017-11-26 23:47:18 +010026" font name that works everywhere (hopefully)
27let fontname = has('win32') ? 'fixedsys' : 'fixed'
28
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010029" Two lists with values: values that work and values that fail.
30" When not listed, "othernum" or "otherstring" is used.
31let test_values = {
Bram Moolenaara2a89732022-08-31 14:46:18 +010032 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010033 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
34 \ 'columns': [[12, 80], [-1, 0, 10]],
35 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
36 \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
37 \ 'helpheight': [[0, 10, 100], [-1]],
38 \ 'history': [[0, 1, 100], [-1, 10001]],
Bram Moolenaarc43a8b82017-02-25 21:12:29 +010039 \ 'iminsert': [[0, 1], [-1, 3, 999]],
40 \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020041 \ 'imstyle': [[0, 1], [-1, 2, 999]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010042 \ 'lines': [[2, 24], [-1, 0, 1]],
Bram Moolenaarbb962262017-03-08 00:01:35 +010043 \ 'linespace': [[0, 2, 4], ['']],
Bram Moolenaarf8a07122019-07-01 22:06:07 +020044 \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010045 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
46 \ 'report': [[0, 1, 2, 9999], [-1]],
47 \ 'scroll': [[0, 1, 2, 20], [-1]],
48 \ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
49 \ 'scrolloff': [[0, 1, 2, 20], [-1]],
50 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
51 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
52 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
53 \ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
54 \ 'textwidth': [[0, 1, 8, 99], [-1]],
55 \ 'timeoutlen': [[0, 8, 99999], [-1]],
56 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
57 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
58 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
59 \ 'verbose': [[-1, 0, 1, 8, 9999], []],
Milly40c6bab2024-10-04 20:41:14 +020060 \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '<Esc>', '<t_xx>'],
61 \ ['', 'xxx', '<xxx>', '<Esc', '<C-C>', '<NL>', '<CR>', K_KENTER]],
62 \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '<Esc>'],
63 \ ['', 'xxx', '<xxx>', '<Esc', '<C-C>', '<NL>', '<CR>', K_KENTER]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010064 \ 'winheight': [[1, 10, 999], [-1, 0]],
65 \ 'winminheight': [[0, 1], [-1]],
66 \ 'winminwidth': [[0, 1, 10], [-1]],
67 \ 'winwidth': [[1, 10, 999], [-1, 0]],
68 \
69 \ 'ambiwidth': [['', 'single'], ['xxx']],
70 \ 'background': [['', 'light', 'dark'], ['xxx']],
Bram Moolenaaraa0489e2020-04-17 19:41:21 +020071 \ 'backspace': [[0, 2, 3, '', 'eol', 'eol,start', 'indent,eol,nostop'], ['4', 'xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010072 \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
73 \ 'backupext': [['xxx'], ['']],
74 \ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
75 \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010076 \ 'browsedir': [['', 'last', '/'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010077 \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
78 \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
79 \ 'casemap': [['', 'internal'], ['xxx']],
Milly25732432024-10-01 19:30:20 +020080 \ 'cedit': [['', '^Y', '<Esc>'], ['xxx', 'f', '<xxx>']],
Bram Moolenaar531be472020-09-23 22:38:05 +020081 \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*', 'exclude:\\%(']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010082 \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
83 \ 'comments': [['', 'b:#'], ['xxx']],
Riley Bruins0a083062024-06-03 20:40:45 +020084 \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010085 \ 'complete': [['', 'w,b'], ['xxx']],
86 \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
87 \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
glepnir6a89c942024-10-01 20:32:12 +020088 \ 'completeitemalign': [['abbr,kind,menu'], ['xxx','abbr,menu','abbr,menu,kind,abbr', 'abbr', 'abbr1234,kind', '']],
Bram Moolenaarbd483b32019-08-21 15:13:41 +020089 \ 'completepopup': [['', 'height:13', 'highlight:That', 'width:10,height:234,highlight:Mine'], ['height:yes', 'width:no', 'xxx', 'xxx:99', 'border:maybe', 'border:1']],
Bram Moolenaard4404b42019-07-28 18:38:09 +020090 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010091 \ 'cryptmethod': [['', 'zip'], ['xxx']],
92 \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
Bram Moolenaar017ba072019-09-14 21:01:23 +020093 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline', 'line,number'], ['', 'xxx', 'line,screenline']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010094 \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
Bram Moolenaard0721052018-11-05 21:21:33 +010095 \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx', 'algorithm:xxx', 'algorithm:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010096 \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
97 \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
98 \ 'encoding': [['latin1'], ['xxx', '']],
Yegappan Lakshmanan00e977c2022-06-01 12:31:53 +010099 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100100 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
101 \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
102 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
103 \ 'fillchars': [['', 'vert:x'], ['xxx']],
104 \ 'foldclose': [['', 'all'], ['xxx']],
105 \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
106 \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
107 \ 'foldmarker': [['((,))'], ['', 'xxx']],
108 \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
109 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100110 \ 'guifont': [['', fontname], []],
111 \ 'guifontwide': [['', fontname], []],
112 \ 'guifontset': [['', fontname], []],
Yegappan Lakshmanan6d611de2023-02-25 11:59:33 +0000113 \ 'guioptions': [['', 'a'], ['Q']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100114 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
115 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200116 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100117 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
118 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
119 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
120 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
Yegappan Lakshmanan87018252023-09-20 20:20:04 +0200121 \ 'jumpoptions': [['', 'stack'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100122 \ 'keymap': [['', 'accents'], ['xxx']],
123 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
Bram Moolenaar63a2e362022-11-23 20:20:18 +0000124 \ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
125 \ [':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100126 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
Bram Moolenaarc8b67352022-10-15 16:41:53 +0100127 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100128 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
129 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
130 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
131 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
132 \ 'mousemodel': [['', 'popup'], ['xxx']],
133 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
134 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
Bram Moolenaar79648732019-07-18 21:43:07 +0200135 \ 'previewpopup': [['', 'height:13', 'width:10,height:234'], ['height:yes', 'xxx', 'xxx:99']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100136 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
137 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
138 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100139 \ 'renderoptions': [[''], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000140 \ 'rightleftcmd': [['search'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100141 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
142 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
143 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
Luuk van Baalba936f62022-12-15 13:15:39 +0000144 \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100145 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
Bram Moolenaarb2620202020-10-30 19:25:09 +0100146 \ 'spellfile': [['', 'file.en.add', '/tmp/dir\ with\ space/en.utf-8.add'], ['xxx', '/tmp/file']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200147 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200148 \ 'spelloptions': [['', 'camel'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100149 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
Luuk van Baal13ece2a2022-10-03 15:28:08 +0100150 \ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000151 \ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100152 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
LemonBoy5247b0b2024-07-12 19:30:58 +0200153 \ 'tabclose': [['', 'left', 'left,uselast'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100154 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100155 \ 'term': [[], []],
Bram Moolenaarcafafb32018-02-22 21:07:09 +0100156 \ 'termguicolors': [[], []],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100157 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200158 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100159 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100160 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
161 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
162 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100163 \ 'ttytype': [[], []],
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200164 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
165 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100166 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
167 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
168 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
169 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
Bram Moolenaar91ffc8a2020-03-02 20:54:22 +0100170 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx', 'a4', 'full,full,full,full,full']],
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +0000171 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100172 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
173 \
174 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100175 \ 'perldll': [[], []],
176 \ 'pythondll': [[], []],
177 \ 'pythonthreedll': [[], []],
178 \ 'pyxversion': [[], []],
179 \ 'rubydll': [[], []],
180 \ 'tcldll': [[], []],
181 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100182 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100183 \ 'otherstring': [['', 'xxx'], []],
184 \}
185
1861
187/struct vimoption options
188while 1
189 /{"
190 if line('.') > end
191 break
192 endif
193 let line = getline('.')
194 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
195 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
196
197 if has_key(test_values, name)
198 let a = test_values[name]
199 elseif line =~ 'P_NUM'
200 let a = test_values['othernum']
201 else
202 let a = test_values['otherstring']
203 endif
204 if len(a[0]) > 0 || len(a[1]) > 0
205 if line =~ 'P_BOOL'
206 call add(script, 'set ' . name)
207 call add(script, 'set ' . shortname)
208 call add(script, 'set no' . name)
209 call add(script, 'set no' . shortname)
210 else
211 for val in a[0]
212 call add(script, 'set ' . name . '=' . val)
213 call add(script, 'set ' . shortname . '=' . val)
214 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100215
216 " setting an option can only fail when it's implemented.
217 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100218 for val in a[1]
Bram Moolenaar28ee8922020-10-28 20:20:00 +0100219 call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
220 call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100221 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100222 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100223 endif
224
Bram Moolenaar17471e82017-11-26 23:47:18 +0100225 " cannot change 'termencoding' in GTK
226 if name != 'termencoding' || !has('gui_gtk')
227 call add(script, 'set ' . name . '&')
228 call add(script, 'set ' . shortname . '&')
229 endif
Bram Moolenaarb4c55722017-03-19 19:11:35 +0100230 if name == 'verbosefile'
231 call add(script, 'call delete("xxx")')
232 endif
Bram Moolenaar65408f72017-03-07 21:31:27 +0100233
234 if name == 'more'
235 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100236 elseif name == 'lines'
237 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100238 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100239 endif
240endwhile
241
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100242call add(script, 'let &columns = save_columns')
243call add(script, 'let &lines = save_lines')
244
Bram Moolenaare8512d72017-03-07 22:33:32 +0100245call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100246
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100247endif
248
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100249qa!