blob: f205d4391f3c06f23941041df64ca0fe1d5d243c [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
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010010" The terminal size is restored at the end.
11" Clear out t_WS, we don't want to resize the actual terminal.
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010012let script = [
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010013 \ '" DO NOT EDIT: Generated with gen_opt_test.vim',
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +000014 \ '" Used by test_options.vim.',
Bram Moolenaar0c1e3742019-12-27 13:49:24 +010015 \ '',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010016 \ 'let save_columns = &columns',
17 \ 'let save_lines = &lines',
Bram Moolenaaree1dd1c2017-03-09 13:55:01 +010018 \ 'set t_WS=',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010019 \ ]
20
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010021/#define p_term
22let end = line('.')
23
Bram Moolenaar17471e82017-11-26 23:47:18 +010024" font name that works everywhere (hopefully)
25let fontname = has('win32') ? 'fixedsys' : 'fixed'
26
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010027" Two lists with values: values that work and values that fail.
28" When not listed, "othernum" or "otherstring" is used.
29let test_values = {
Bram Moolenaara2a89732022-08-31 14:46:18 +010030 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010031 \ 'cmdwinheight': [[1, 2, 10], [-1, 0]],
32 \ 'columns': [[12, 80], [-1, 0, 10]],
33 \ 'conceallevel': [[0, 1, 2, 3], [-1, 4, 99]],
34 \ 'foldcolumn': [[0, 1, 4, 12], [-1, 13, 999]],
35 \ 'helpheight': [[0, 10, 100], [-1]],
36 \ 'history': [[0, 1, 100], [-1, 10001]],
Bram Moolenaarc43a8b82017-02-25 21:12:29 +010037 \ 'iminsert': [[0, 1], [-1, 3, 999]],
38 \ 'imsearch': [[-1, 0, 1], [-2, 3, 999]],
Bram Moolenaar5c6dbcb2017-08-30 22:00:20 +020039 \ 'imstyle': [[0, 1], [-1, 2, 999]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010040 \ 'lines': [[2, 24], [-1, 0, 1]],
Bram Moolenaarbb962262017-03-08 00:01:35 +010041 \ 'linespace': [[0, 2, 4], ['']],
Bram Moolenaarf8a07122019-07-01 22:06:07 +020042 \ 'numberwidth': [[1, 4, 8, 10, 11, 20], [-1, 0, 21]],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010043 \ 'regexpengine': [[0, 1, 2], [-1, 3, 999]],
44 \ 'report': [[0, 1, 2, 9999], [-1]],
45 \ 'scroll': [[0, 1, 2, 20], [-1]],
46 \ 'scrolljump': [[-50, -1, 0, 1, 2, 20], [999]],
47 \ 'scrolloff': [[0, 1, 2, 20], [-1]],
48 \ 'shiftwidth': [[0, 1, 8, 999], [-1]],
49 \ 'sidescroll': [[0, 1, 8, 999], [-1]],
50 \ 'sidescrolloff': [[0, 1, 8, 999], [-1]],
51 \ 'tabstop': [[1, 4, 8, 12], [-1, 0]],
52 \ 'textwidth': [[0, 1, 8, 99], [-1]],
53 \ 'timeoutlen': [[0, 8, 99999], [-1]],
54 \ 'titlelen': [[0, 1, 8, 9999], [-1]],
55 \ 'updatecount': [[0, 1, 8, 9999], [-1]],
56 \ 'updatetime': [[0, 1, 8, 9999], [-1]],
57 \ 'verbose': [[-1, 0, 1, 8, 9999], []],
Bram Moolenaara12e4032017-02-25 21:37:57 +010058 \ 'wildcharm': [[-1, 0, 100], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010059 \ 'winheight': [[1, 10, 999], [-1, 0]],
60 \ 'winminheight': [[0, 1], [-1]],
61 \ 'winminwidth': [[0, 1, 10], [-1]],
62 \ 'winwidth': [[1, 10, 999], [-1, 0]],
63 \
64 \ 'ambiwidth': [['', 'single'], ['xxx']],
65 \ 'background': [['', 'light', 'dark'], ['xxx']],
Bram Moolenaaraa0489e2020-04-17 19:41:21 +020066 \ 'backspace': [[0, 2, 3, '', 'eol', 'eol,start', 'indent,eol,nostop'], ['4', 'xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010067 \ 'backupcopy': [['yes', 'auto'], ['', 'xxx', 'yes,no']],
68 \ 'backupext': [['xxx'], ['']],
69 \ 'belloff': [['', 'all', 'copy,error'], ['xxx']],
70 \ 'breakindentopt': [['', 'min:3', 'sbr'], ['xxx', 'min', 'min:x']],
Bram Moolenaarbb962262017-03-08 00:01:35 +010071 \ 'browsedir': [['', 'last', '/'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010072 \ 'bufhidden': [['', 'hide', 'wipe'], ['xxx', 'hide,wipe']],
73 \ 'buftype': [['', 'help', 'nofile'], ['xxx', 'help,nofile']],
74 \ 'casemap': [['', 'internal'], ['xxx']],
75 \ 'cedit': [['', '\<Esc>'], ['xxx', 'f']],
Bram Moolenaar531be472020-09-23 22:38:05 +020076 \ 'clipboard': [['', 'unnamed', 'autoselect,unnamed', 'html', 'exclude:vimdisplay'], ['xxx', '\ze*', 'exclude:\\%(']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010077 \ 'colorcolumn': [['', '8', '+2'], ['xxx']],
78 \ 'comments': [['', 'b:#'], ['xxx']],
79 \ 'commentstring': [['', '/*%s*/'], ['xxx']],
80 \ 'complete': [['', 'w,b'], ['xxx']],
81 \ 'concealcursor': [['', 'n', 'nvic'], ['xxx']],
82 \ 'completeopt': [['', 'menu', 'menu,longest'], ['xxx', 'menu,,,longest,']],
Bram Moolenaarbd483b32019-08-21 15:13:41 +020083 \ '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 +020084 \ 'completeslash': [['', 'slash', 'backslash'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010085 \ 'cryptmethod': [['', 'zip'], ['xxx']],
86 \ 'cscopequickfix': [['', 's-', 's-,c+,e0'], ['xxx', 's,g,d']],
Bram Moolenaar017ba072019-09-14 21:01:23 +020087 \ 'cursorlineopt': [['both', 'line', 'number', 'screenline', 'line,number'], ['', 'xxx', 'line,screenline']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010088 \ 'debug': [['', 'msg', 'msg', 'beep'], ['xxx']],
Bram Moolenaard0721052018-11-05 21:21:33 +010089 \ 'diffopt': [['', 'filler', 'icase,iwhite'], ['xxx', 'algorithm:xxx', 'algorithm:']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010090 \ 'display': [['', 'lastline', 'lastline,uhex'], ['xxx']],
91 \ 'eadirection': [['', 'both', 'ver'], ['xxx', 'ver,hor']],
92 \ 'encoding': [['latin1'], ['xxx', '']],
Yegappan Lakshmanan00e977c2022-06-01 12:31:53 +010093 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter', 'all,WinEnter'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010094 \ 'fileencoding': [['', 'latin1', 'xxx'], []],
95 \ 'fileformat': [['', 'dos', 'unix'], ['xxx']],
96 \ 'fileformats': [['', 'dos', 'dos,unix'], ['xxx']],
97 \ 'fillchars': [['', 'vert:x'], ['xxx']],
98 \ 'foldclose': [['', 'all'], ['xxx']],
99 \ 'foldmethod': [['manual', 'indent'], ['', 'xxx', 'expr,diff']],
100 \ 'foldopen': [['', 'all', 'hor,jump'], ['xxx']],
101 \ 'foldmarker': [['((,))'], ['', 'xxx']],
102 \ 'formatoptions': [['', 'vt', 'v,t'], ['xxx']],
103 \ 'guicursor': [['', 'n:block-Cursor'], ['xxx']],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100104 \ 'guifont': [['', fontname], []],
105 \ 'guifontwide': [['', fontname], []],
106 \ 'guifontset': [['', fontname], []],
Yegappan Lakshmanan6d611de2023-02-25 11:59:33 +0000107 \ 'guioptions': [['', 'a'], ['Q']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100108 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
109 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200110 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100111 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
112 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
113 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
114 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
115 \ 'keymap': [['', 'accents'], ['xxx']],
116 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
Bram Moolenaar63a2e362022-11-23 20:20:18 +0000117 \ 'keyprotocol': [['', 'xxx:none', 'yyy:mok2', 'zzz:kitty'],
118 \ [':none', 'xxx:', 'x:non', 'y:mok3', 'z:kittty']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100119 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
Bram Moolenaarc8b67352022-10-15 16:41:53 +0100120 \ 'lispoptions': [['', 'expr:0', 'expr:1'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100121 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
122 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
123 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
124 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
125 \ 'mousemodel': [['', 'popup'], ['xxx']],
126 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
127 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
Bram Moolenaar79648732019-07-18 21:43:07 +0200128 \ 'previewpopup': [['', 'height:13', 'width:10,height:234'], ['height:yes', 'xxx', 'xxx:99']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100129 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
130 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
131 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100132 \ 'renderoptions': [[''], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000133 \ 'rightleftcmd': [['search'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100134 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
135 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
136 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
Luuk van Baalba936f62022-12-15 13:15:39 +0000137 \ 'showcmdloc': [['last', 'statusline', 'tabline'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100138 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
Bram Moolenaarb2620202020-10-30 19:25:09 +0100139 \ 'spellfile': [['', 'file.en.add', '/tmp/dir\ with\ space/en.utf-8.add'], ['xxx', '/tmp/file']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200140 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200141 \ 'spelloptions': [['', 'camel'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100142 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
Luuk van Baal13ece2a2022-10-03 15:28:08 +0100143 \ 'splitkeep': [['cursor', 'screen', 'topline'], ['xxx']],
Yegappan Lakshmanan5da901b2023-02-27 12:47:47 +0000144 \ 'swapsync': [['', 'sync', 'fsync'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100145 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
146 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100147 \ 'term': [[], []],
Bram Moolenaarcafafb32018-02-22 21:07:09 +0100148 \ 'termguicolors': [[], []],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100149 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200150 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100151 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100152 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
153 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
154 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100155 \ 'ttytype': [[], []],
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200156 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
157 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100158 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
159 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
160 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
161 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
Bram Moolenaar91ffc8a2020-03-02 20:54:22 +0100162 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx', 'a4', 'full,full,full,full,full']],
Yegappan Lakshmanan38b85cb2022-02-24 13:28:41 +0000163 \ 'wildoptions': [['', 'tagfile', 'pum', 'fuzzy'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100164 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
165 \
166 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100167 \ 'perldll': [[], []],
168 \ 'pythondll': [[], []],
169 \ 'pythonthreedll': [[], []],
170 \ 'pyxversion': [[], []],
171 \ 'rubydll': [[], []],
172 \ 'tcldll': [[], []],
173 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100174 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100175 \ 'otherstring': [['', 'xxx'], []],
176 \}
177
1781
179/struct vimoption options
180while 1
181 /{"
182 if line('.') > end
183 break
184 endif
185 let line = getline('.')
186 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
187 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
188
189 if has_key(test_values, name)
190 let a = test_values[name]
191 elseif line =~ 'P_NUM'
192 let a = test_values['othernum']
193 else
194 let a = test_values['otherstring']
195 endif
196 if len(a[0]) > 0 || len(a[1]) > 0
197 if line =~ 'P_BOOL'
198 call add(script, 'set ' . name)
199 call add(script, 'set ' . shortname)
200 call add(script, 'set no' . name)
201 call add(script, 'set no' . shortname)
202 else
203 for val in a[0]
204 call add(script, 'set ' . name . '=' . val)
205 call add(script, 'set ' . shortname . '=' . val)
206 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100207
208 " setting an option can only fail when it's implemented.
209 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100210 for val in a[1]
Bram Moolenaar28ee8922020-10-28 20:20:00 +0100211 call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
212 call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100213 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100214 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100215 endif
216
Bram Moolenaar17471e82017-11-26 23:47:18 +0100217 " cannot change 'termencoding' in GTK
218 if name != 'termencoding' || !has('gui_gtk')
219 call add(script, 'set ' . name . '&')
220 call add(script, 'set ' . shortname . '&')
221 endif
Bram Moolenaarb4c55722017-03-19 19:11:35 +0100222 if name == 'verbosefile'
223 call add(script, 'call delete("xxx")')
224 endif
Bram Moolenaar65408f72017-03-07 21:31:27 +0100225
226 if name == 'more'
227 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100228 elseif name == 'lines'
229 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100230 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100231 endif
232endwhile
233
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100234call add(script, 'let &columns = save_columns')
235call add(script, 'let &lines = save_lines')
236
Bram Moolenaare8512d72017-03-07 22:33:32 +0100237call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100238
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100239endif
240
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100241qa!