blob: 4ca3c09386e717452ed3796b386ff40a01bfa1e8 [file] [log] [blame]
Millyd4ad4c92024-10-06 16:27:28 +02001" Script to generate testdir/opt_test.vim from optiondefs.h
Bram Moolenaar2f5463d2017-02-25 20:40:46 +01002
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
Millyd4ad4c92024-10-06 16:27:28 +02008try
9
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010010set nomore
11
Milly40c6bab2024-10-04 20:41:14 +020012const K_KENTER = -16715
13
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010014" The terminal size is restored at the end.
15" Clear out t_WS, we don't want to resize the actual terminal.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010016let script = [
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010017 \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +000018 \ '" Used by test_options.vim.',
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010019 \ '',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010020 \ 'let save_columns = &columns',
21 \ 'let save_lines = &lines',
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010022 \ 'set t_WS=',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010023 \ ]
24
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010025/#define p_term
26let end = line('.')
27
Bram Moolenaar17471e82017-11-26 23:47:18 +010028" font name that works everywhere (hopefully)
29let fontname = has('win32') ? 'fixedsys' : 'fixed'
30
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010031" Two lists with values: values that work and values that fail.
32" When not listed, "othernum" or "otherstring" is used.
33let test_values = {
Bram Moolenaara2a89732022-08-31 14:46:18 +010034 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010035 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
36 \ 'columns': [[12, 80], [-1, 0, 10]],
37 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
38 \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
39 \ 'helpheight': [[0, 10, 100], [-1]],
40 \ 'history': [[0, 1, 100], [-1, 10001]],
Bram Moolenaarc43a8b82017-02-25 21:12:29 +010041 \ 'iminsert': [[0, 1], [-1, 3, 999]],
42 \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020043 \ 'imstyle': [[0, 1], [-1, 2, 999]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010044 \ 'lines': [[2, 24], [-1, 0, 1]],
Bram Moolenaarbb962262017-03-08 00:01:35 +010045 \ 'linespace': [[0, 2, 4], ['']],
Bram Moolenaarf8a07122019-07-01 22:06:07 +020046 \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010047 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
48 \ 'report': [[0, 1, 2, 9999], [-1]],
49 \ 'scroll': [[0, 1, 2, 20], [-1]],
50 \ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
51 \ 'scrolloff': [[0, 1, 2, 20], [-1]],
52 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
53 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
54 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
55 \ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
56 \ 'textwidth': [[0, 1, 8, 99], [-1]],
57 \ 'timeoutlen': [[0, 8, 99999], [-1]],
58 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
59 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
60 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
61 \ 'verbose': [[-1, 0, 1, 8, 9999], []],
Millya9c6f902024-10-06 16:47:02 +020062 \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<t_xx>', '<', '^'],
63 \ ['', 'xxx', '<xxx>', '<Esc', '<t_xx', '<C-C>', '<NL>', '<CR>', K_KENTER]],
64 \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '^@', '<Esc>', '<', '^'],
65 \ ['', 'xxx', '<xxx>', '<Esc', '<t_xx', '<C-C>', '<NL>', '<CR>', K_KENTER]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010066 \ 'winheight': [[1, 10, 999], [-1, 0]],
67 \ 'winminheight': [[0, 1], [-1]],
68 \ 'winminwidth': [[0, 1, 10], [-1]],
69 \ 'winwidth': [[1, 10, 999], [-1, 0]],
70 \
71 \ 'ambiwidth': [['', 'single'], ['xxx']],
72 \ 'background': [['', 'light', 'dark'], ['xxx']],
Bram Moolenaaraa0489e2020-04-17 19:41:21 +020073 \ 'backspace': [[0, 2, 3, '', 'eol', 'eol,start', 'indent,eol,nostop'], ['4', 'xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010074 \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
75 \ 'backupext': [['xxx'], ['']],
76 \ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
77 \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010078 \ 'browsedir': [['', 'last', '/'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010079 \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
80 \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
81 \ 'casemap': [['', 'internal'], ['xxx']],
Millya9c6f902024-10-06 16:47:02 +020082 \ 'cedit': [['', '^Y', '^@', '<Esc>', '<t_xx>'],
83 \ ['xxx', 'f', '<xxx>', '<Esc', '<t_xx']],
Bram Moolenaar531be472020-09-23 22:38:05 +020084 \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*', 'exclude:\\%(']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010085 \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
86 \ 'comments': [['', 'b:#'], ['xxx']],
Riley Bruins0a083062024-06-03 20:40:45 +020087 \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010088 \ 'complete': [['', 'w,b'], ['xxx']],
89 \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
90 \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
glepnir6a89c942024-10-01 20:32:12 +020091 \ 'completeitemalign': [['abbr,kind,menu'], ['xxx','abbr,menu','abbr,menu,kind,abbr', 'abbr', 'abbr1234,kind', '']],
Bram Moolenaarbd483b32019-08-21 15:13:41 +020092 \ '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 +020093 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010094 \ 'cryptmethod': [['', 'zip'], ['xxx']],
95 \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
Bram Moolenaar017ba072019-09-14 21:01:23 +020096 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline', 'line,number'], ['', 'xxx', 'line,screenline']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010097 \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
Bram Moolenaard0721052018-11-05 21:21:33 +010098 \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx', 'algorithm:xxx', 'algorithm:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010099 \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
100 \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
101 \ 'encoding': [['latin1'], ['xxx', '']],
Yegappan Lakshmanan00e977c2022-06-01 12:31:53 +0100102 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100103 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
104 \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
105 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
106 \ 'fillchars': [['', 'vert:x'], ['xxx']],
107 \ 'foldclose': [['', 'all'], ['xxx']],
108 \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
109 \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
110 \ 'foldmarker': [['((,))'], ['', 'xxx']],
111 \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
112 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100113 \ 'guifont': [['', fontname], []],
114 \ 'guifontwide': [['', fontname], []],
115 \ 'guifontset': [['', fontname], []],
Yegappan Lakshmanan6d611de2023-02-25 11:59:33 +0000116 \ 'guioptions': [['', 'a'], ['Q']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100117 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
118 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200119 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100120 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
121 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
122 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
123 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
Yegappan Lakshmanan87018252023-09-20 20:20:04 +0200124 \ 'jumpoptions': [['', 'stack'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100125 \ 'keymap': [['', 'accents'], ['xxx']],
126 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
Bram Moolenaar63a2e362022-11-23 20:20:18 +0000127 \ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
128 \ [':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100129 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
Bram Moolenaarc8b67352022-10-15 16:41:53 +0100130 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100131 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
132 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
133 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
134 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
135 \ 'mousemodel': [['', 'popup'], ['xxx']],
136 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
137 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
Bram Moolenaar79648732019-07-18 21:43:07 +0200138 \ 'previewpopup': [['', 'height:13', 'width:10,height:234'], ['height:yes', 'xxx', 'xxx:99']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100139 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
140 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
141 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100142 \ 'renderoptions': [[''], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000143 \ 'rightleftcmd': [['search'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100144 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
145 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
146 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
Luuk van Baalba936f62022-12-15 13:15:39 +0000147 \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100148 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
Milly322ad0c2024-10-14 20:21:48 +0200149 \ 'spellfile': [['', 'file.en.add', 'xxx.en.add,yyy.gb.add,zzz.ja.add',
150 \ '/tmp/dir\ with\ space/en.utf-8.add',
151 \ '/tmp/dir\\,with\\,comma/en.utf-8.add'],
152 \ ['xxx', '/tmp/file', ',file.en.add', 'xxx,yyy.en.add',
153 \ 'xxx.en.add,yyy,zzz.ja.add']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200154 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200155 \ 'spelloptions': [['', 'camel'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100156 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
Luuk van Baal13ece2a2022-10-03 15:28:08 +0100157 \ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000158 \ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100159 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
LemonBoy5247b0b2024-07-12 19:30:58 +0200160 \ 'tabclose': [['', 'left', 'left,uselast'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100161 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100162 \ 'term': [[], []],
Bram Moolenaarcafafb32018-02-22 21:07:09 +0100163 \ 'termguicolors': [[], []],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100164 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Millya9c6f902024-10-06 16:47:02 +0200165 \ 'termwinkey': [['', 'f', '^Y', '^@', '<Esc>', '<t_xx>', "\u3042", '<', '^'],
166 \ ['<xxx>', '<Esc', '<t_xx']],
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200167 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100168 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100169 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
170 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
171 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100172 \ 'ttytype': [[], []],
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200173 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
174 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100175 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
176 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
177 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
178 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
Bram Moolenaar91ffc8a2020-03-02 20:54:22 +0100179 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx', 'a4', 'full,full,full,full,full']],
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +0000180 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100181 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
182 \
183 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100184 \ 'perldll': [[], []],
185 \ 'pythondll': [[], []],
186 \ 'pythonthreedll': [[], []],
187 \ 'pyxversion': [[], []],
188 \ 'rubydll': [[], []],
189 \ 'tcldll': [[], []],
190 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100191 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100192 \ 'otherstring': [['', 'xxx'], []],
193 \}
194
1951
196/struct vimoption options
197while 1
198 /{"
199 if line('.') > end
200 break
201 endif
202 let line = getline('.')
203 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
204 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
205
206 if has_key(test_values, name)
207 let a = test_values[name]
208 elseif line =~ 'P_NUM'
209 let a = test_values['othernum']
210 else
211 let a = test_values['otherstring']
212 endif
213 if len(a[0]) > 0 || len(a[1]) > 0
214 if line =~ 'P_BOOL'
215 call add(script, 'set ' . name)
216 call add(script, 'set ' . shortname)
217 call add(script, 'set no' . name)
218 call add(script, 'set no' . shortname)
219 else
220 for val in a[0]
221 call add(script, 'set ' . name . '=' . val)
222 call add(script, 'set ' . shortname . '=' . val)
223 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100224
225 " setting an option can only fail when it's implemented.
226 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100227 for val in a[1]
Bram Moolenaar28ee8922020-10-28 20:20:00 +0100228 call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
229 call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100230 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100231 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100232 endif
233
Bram Moolenaar17471e82017-11-26 23:47:18 +0100234 " cannot change 'termencoding' in GTK
235 if name != 'termencoding' || !has('gui_gtk')
236 call add(script, 'set ' . name . '&')
237 call add(script, 'set ' . shortname . '&')
238 endif
Bram Moolenaarb4c55722017-03-19 19:11:35 +0100239 if name == 'verbosefile'
240 call add(script, 'call delete("xxx")')
241 endif
Bram Moolenaar65408f72017-03-07 21:31:27 +0100242
243 if name == 'more'
244 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100245 elseif name == 'lines'
246 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100247 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100248 endif
249endwhile
250
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100251call add(script, 'let &columns = save_columns')
252call add(script, 'let &lines = save_lines')
253
Bram Moolenaare8512d72017-03-07 22:33:32 +0100254call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100255
Millyd4ad4c92024-10-06 16:27:28 +0200256" Exit with error-code if error occurs.
257catch
258 set verbose=1
259 echoc 'Error:' v:exception 'in' v:throwpoint
260 cq! 1
261endtry
262
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100263endif
264
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100265qa!