blob: 09db320eeee4865c70db10212001c5c996a7f6a9 [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], []],
Milly40c6bab2024-10-04 20:41:14 +020062 \ 'wildchar': [[-1, 0, 100, 'x', '^Y', '<Esc>', '<t_xx>'],
63 \ ['', 'xxx', '<xxx>', '<Esc', '<C-C>', '<NL>', '<CR>', K_KENTER]],
64 \ 'wildcharm': [[-1, 0, 100, 'x', '^Y', '<Esc>'],
65 \ ['', 'xxx', '<xxx>', '<Esc', '<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']],
Milly25732432024-10-01 19:30:20 +020082 \ 'cedit': [['', '^Y', '<Esc>'], ['xxx', 'f', '<xxx>']],
Bram Moolenaar531be472020-09-23 22:38:05 +020083 \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*', 'exclude:\\%(']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010084 \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
85 \ 'comments': [['', 'b:#'], ['xxx']],
Riley Bruins0a083062024-06-03 20:40:45 +020086 \ 'commentstring': [['', '/*\ %s\ */'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010087 \ 'complete': [['', 'w,b'], ['xxx']],
88 \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
89 \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
glepnir6a89c942024-10-01 20:32:12 +020090 \ 'completeitemalign': [['abbr,kind,menu'], ['xxx','abbr,menu','abbr,menu,kind,abbr', 'abbr', 'abbr1234,kind', '']],
Bram Moolenaarbd483b32019-08-21 15:13:41 +020091 \ '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 +020092 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010093 \ 'cryptmethod': [['', 'zip'], ['xxx']],
94 \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
Bram Moolenaar017ba072019-09-14 21:01:23 +020095 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline', 'line,number'], ['', 'xxx', 'line,screenline']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010096 \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
Bram Moolenaard0721052018-11-05 21:21:33 +010097 \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx', 'algorithm:xxx', 'algorithm:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010098 \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
99 \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
100 \ 'encoding': [['latin1'], ['xxx', '']],
Yegappan Lakshmanan00e977c2022-06-01 12:31:53 +0100101 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100102 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
103 \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
104 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
105 \ 'fillchars': [['', 'vert:x'], ['xxx']],
106 \ 'foldclose': [['', 'all'], ['xxx']],
107 \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
108 \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
109 \ 'foldmarker': [['((,))'], ['', 'xxx']],
110 \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
111 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100112 \ 'guifont': [['', fontname], []],
113 \ 'guifontwide': [['', fontname], []],
114 \ 'guifontset': [['', fontname], []],
Yegappan Lakshmanan6d611de2023-02-25 11:59:33 +0000115 \ 'guioptions': [['', 'a'], ['Q']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100116 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
117 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200118 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100119 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
120 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
121 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
122 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
Yegappan Lakshmanan87018252023-09-20 20:20:04 +0200123 \ 'jumpoptions': [['', 'stack'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100124 \ 'keymap': [['', 'accents'], ['xxx']],
125 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
Bram Moolenaar63a2e362022-11-23 20:20:18 +0000126 \ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
127 \ [':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100128 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
Bram Moolenaarc8b67352022-10-15 16:41:53 +0100129 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100130 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
131 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
132 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
133 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
134 \ 'mousemodel': [['', 'popup'], ['xxx']],
135 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
136 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
Bram Moolenaar79648732019-07-18 21:43:07 +0200137 \ 'previewpopup': [['', 'height:13', 'width:10,height:234'], ['height:yes', 'xxx', 'xxx:99']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100138 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
139 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
140 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100141 \ 'renderoptions': [[''], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000142 \ 'rightleftcmd': [['search'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100143 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
144 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
145 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
Luuk van Baalba936f62022-12-15 13:15:39 +0000146 \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100147 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
Bram Moolenaarb2620202020-10-30 19:25:09 +0100148 \ 'spellfile': [['', 'file.en.add', '/tmp/dir\ with\ space/en.utf-8.add'], ['xxx', '/tmp/file']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200149 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200150 \ 'spelloptions': [['', 'camel'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100151 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
Luuk van Baal13ece2a2022-10-03 15:28:08 +0100152 \ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000153 \ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100154 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
LemonBoy5247b0b2024-07-12 19:30:58 +0200155 \ 'tabclose': [['', 'left', 'left,uselast'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100156 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100157 \ 'term': [[], []],
Bram Moolenaarcafafb32018-02-22 21:07:09 +0100158 \ 'termguicolors': [[], []],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100159 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200160 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100161 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100162 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
163 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
164 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100165 \ 'ttytype': [[], []],
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200166 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
167 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100168 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
169 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
170 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
171 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
Bram Moolenaar91ffc8a2020-03-02 20:54:22 +0100172 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx', 'a4', 'full,full,full,full,full']],
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +0000173 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100174 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
175 \
176 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100177 \ 'perldll': [[], []],
178 \ 'pythondll': [[], []],
179 \ 'pythonthreedll': [[], []],
180 \ 'pyxversion': [[], []],
181 \ 'rubydll': [[], []],
182 \ 'tcldll': [[], []],
183 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100184 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100185 \ 'otherstring': [['', 'xxx'], []],
186 \}
187
1881
189/struct vimoption options
190while 1
191 /{"
192 if line('.') > end
193 break
194 endif
195 let line = getline('.')
196 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
197 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
198
199 if has_key(test_values, name)
200 let a = test_values[name]
201 elseif line =~ 'P_NUM'
202 let a = test_values['othernum']
203 else
204 let a = test_values['otherstring']
205 endif
206 if len(a[0]) > 0 || len(a[1]) > 0
207 if line =~ 'P_BOOL'
208 call add(script, 'set ' . name)
209 call add(script, 'set ' . shortname)
210 call add(script, 'set no' . name)
211 call add(script, 'set no' . shortname)
212 else
213 for val in a[0]
214 call add(script, 'set ' . name . '=' . val)
215 call add(script, 'set ' . shortname . '=' . val)
216 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100217
218 " setting an option can only fail when it's implemented.
219 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100220 for val in a[1]
Bram Moolenaar28ee8922020-10-28 20:20:00 +0100221 call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
222 call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100223 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100224 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100225 endif
226
Bram Moolenaar17471e82017-11-26 23:47:18 +0100227 " cannot change 'termencoding' in GTK
228 if name != 'termencoding' || !has('gui_gtk')
229 call add(script, 'set ' . name . '&')
230 call add(script, 'set ' . shortname . '&')
231 endif
Bram Moolenaarb4c55722017-03-19 19:11:35 +0100232 if name == 'verbosefile'
233 call add(script, 'call delete("xxx")')
234 endif
Bram Moolenaar65408f72017-03-07 21:31:27 +0100235
236 if name == 'more'
237 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100238 elseif name == 'lines'
239 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100240 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100241 endif
242endwhile
243
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100244call add(script, 'let &columns = save_columns')
245call add(script, 'let &lines = save_lines')
246
Bram Moolenaare8512d72017-03-07 22:33:32 +0100247call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100248
Millyd4ad4c92024-10-06 16:27:28 +0200249" Exit with error-code if error occurs.
250catch
251 set verbose=1
252 echoc 'Error:' v:exception 'in' v:throwpoint
253 cq! 1
254endtry
255
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100256endif
257
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100258qa!