blob: 600a7908068184eff809eb66bd81dc240a83de4c [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',
14 \ '',
Bram Moolenaar2f5463d2017-02-25 20:40:46 +010015 \ 'let save_columns = &columns',
16 \ 'let save_lines = &lines',
17 \ 'let save_term = &term',
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 = {
30 \ 'cmdheight': [[1, 2, 10], [-1, 0]],
31 \ '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', '']],
93 \ 'eventignore': [['', 'WinEnter', 'WinLeave,winenter'], ['xxx']],
94 \ '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], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100107 \ 'helplang': [['', 'de', 'de,it'], ['xxx']],
108 \ 'highlight': [['', 'e:Error'], ['xxx']],
Bram Moolenaar86e57922017-04-23 18:44:26 +0200109 \ 'imactivatekey': [['', 'S-space'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100110 \ 'isfname': [['', '@', '@,48-52'], ['xxx', '@48']],
111 \ 'isident': [['', '@', '@,48-52'], ['xxx', '@48']],
112 \ 'iskeyword': [['', '@', '@,48-52'], ['xxx', '@48']],
113 \ 'isprint': [['', '@', '@,48-52'], ['xxx', '@48']],
114 \ 'keymap': [['', 'accents'], ['xxx']],
115 \ 'keymodel': [['', 'startsel', 'startsel,stopsel'], ['xxx']],
116 \ 'langmap': [['', 'xX', 'aA,bB'], ['xxx']],
117 \ 'listchars': [['', 'eol:x', 'eol:x,space:y'], ['xxx']],
118 \ 'matchpairs': [['', '(:)', '(:),<:>'], ['xxx']],
119 \ 'mkspellmem': [['10000,100,12'], ['', 'xxx']],
120 \ 'mouse': [['', 'a', 'nvi'], ['xxx', 'n,v,i']],
121 \ 'mousemodel': [['', 'popup'], ['xxx']],
122 \ 'mouseshape': [['', 'n:arrow'], ['xxx']],
123 \ 'nrformats': [['', 'alpha', 'alpha,hex,bin'], ['xxx']],
Bram Moolenaar79648732019-07-18 21:43:07 +0200124 \ 'previewpopup': [['', 'height:13', 'width:10,height:234'], ['height:yes', 'xxx', 'xxx:99']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100125 \ 'printmbfont': [['', 'r:some', 'b:Bold,c:yes'], ['xxx']],
126 \ 'printoptions': [['', 'header:0', 'left:10pc,top:5pc'], ['xxx']],
127 \ 'scrollopt': [['', 'ver', 'ver,hor'], ['xxx']],
Bram Moolenaar0c1e3742019-12-27 13:49:24 +0100128 \ 'renderoptions': [[''], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100129 \ 'selection': [['old', 'inclusive'], ['', 'xxx']],
130 \ 'selectmode': [['', 'mouse', 'key,cmd'], ['xxx']],
131 \ 'sessionoptions': [['', 'blank', 'help,options,slash'], ['xxx']],
132 \ 'signcolumn': [['', 'auto', 'no'], ['xxx', 'no,yes']],
133 \ 'spellfile': [['', 'file.en.add'], ['xxx', '/tmp/file']],
Bram Moolenaar9a061cb2019-05-05 16:55:03 +0200134 \ 'spelllang': [['', 'xxx', 'sr@latin'], ['not&lang', "that\\\rthere"]],
Bram Moolenaar362b44b2020-06-10 21:47:00 +0200135 \ 'spelloptions': [['', 'camel'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100136 \ 'spellsuggest': [['', 'best', 'double,33'], ['xxx']],
137 \ 'switchbuf': [['', 'useopen', 'split,newtab'], ['xxx']],
138 \ 'tagcase': [['smart', 'match'], ['', 'xxx', 'smart,match']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100139 \ 'term': [[], []],
Bram Moolenaarcafafb32018-02-22 21:07:09 +0100140 \ 'termguicolors': [[], []],
Bram Moolenaar17471e82017-11-26 23:47:18 +0100141 \ 'termencoding': [has('gui_gtk') ? [] : ['', 'utf-8'], ['xxx']],
Bram Moolenaar6d150f72018-04-21 20:03:20 +0200142 \ 'termwinsize': [['', '24x80', '0x80', '32x0', '0x0'], ['xxx', '80', '8ax9', '24x80b']],
Bram Moolenaarc6ddce32019-02-08 12:47:03 +0100143 \ 'termwintype': [['', 'winpty', 'conpty'], ['xxx']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100144 \ 'toolbar': [['', 'icons', 'text'], ['xxx']],
145 \ 'toolbariconsize': [['', 'tiny', 'huge'], ['xxx']],
146 \ 'ttymouse': [['', 'xterm'], ['xxx']],
Bram Moolenaarbb962262017-03-08 00:01:35 +0100147 \ 'ttytype': [[], []],
Bram Moolenaar04958cb2018-06-23 19:23:02 +0200148 \ 'varsofttabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
149 \ 'vartabstop': [['8', '4,8,16,32'], ['xxx', '-1', '4,-1,20']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100150 \ 'viewoptions': [['', 'cursor', 'unix,slash'], ['xxx']],
151 \ 'viminfo': [['', '''50', '"30'], ['xxx']],
152 \ 'virtualedit': [['', 'all', 'all,block'], ['xxx']],
153 \ 'whichwrap': [['', 'b,s', 'bs'], ['xxx']],
Bram Moolenaar91ffc8a2020-03-02 20:54:22 +0100154 \ 'wildmode': [['', 'full', 'list:full', 'full,longest'], ['xxx', 'a4', 'full,full,full,full,full']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100155 \ 'wildoptions': [['', 'tagfile'], ['xxx']],
156 \ 'winaltkeys': [['menu', 'no'], ['', 'xxx']],
157 \
158 \ 'luadll': [[], []],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100159 \ 'perldll': [[], []],
160 \ 'pythondll': [[], []],
161 \ 'pythonthreedll': [[], []],
162 \ 'pyxversion': [[], []],
163 \ 'rubydll': [[], []],
164 \ 'tcldll': [[], []],
165 \
Bram Moolenaara12e4032017-02-25 21:37:57 +0100166 \ 'othernum': [[-1, 0, 100], ['']],
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100167 \ 'otherstring': [['', 'xxx'], []],
168 \}
169
1701
171/struct vimoption options
172while 1
173 /{"
174 if line('.') > end
175 break
176 endif
177 let line = getline('.')
178 let name = substitute(line, '.*{"\([^"]*\)".*', '\1', '')
179 let shortname = substitute(line, '.*"\([^"]*\)".*', '\1', '')
180
181 if has_key(test_values, name)
182 let a = test_values[name]
183 elseif line =~ 'P_NUM'
184 let a = test_values['othernum']
185 else
186 let a = test_values['otherstring']
187 endif
188 if len(a[0]) > 0 || len(a[1]) > 0
189 if line =~ 'P_BOOL'
190 call add(script, 'set ' . name)
191 call add(script, 'set ' . shortname)
192 call add(script, 'set no' . name)
193 call add(script, 'set no' . shortname)
194 else
195 for val in a[0]
196 call add(script, 'set ' . name . '=' . val)
197 call add(script, 'set ' . shortname . '=' . val)
198 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100199
200 " setting an option can only fail when it's implemented.
201 call add(script, "if exists('+" . name . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100202 for val in a[1]
Bram Moolenaar28ee8922020-10-28 20:20:00 +0100203 call add(script, "silent! call assert_fails('set " . name . "=" . val . "')")
204 call add(script, "silent! call assert_fails('set " . shortname . "=" . val . "')")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100205 endfor
Bram Moolenaarc43a8b82017-02-25 21:12:29 +0100206 call add(script, "endif")
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100207 endif
208
Bram Moolenaar17471e82017-11-26 23:47:18 +0100209 " cannot change 'termencoding' in GTK
210 if name != 'termencoding' || !has('gui_gtk')
211 call add(script, 'set ' . name . '&')
212 call add(script, 'set ' . shortname . '&')
213 endif
Bram Moolenaarb4c55722017-03-19 19:11:35 +0100214 if name == 'verbosefile'
215 call add(script, 'call delete("xxx")')
216 endif
Bram Moolenaar65408f72017-03-07 21:31:27 +0100217
218 if name == 'more'
219 call add(script, 'set nomore')
Bram Moolenaarbb962262017-03-08 00:01:35 +0100220 elseif name == 'lines'
221 call add(script, 'let &lines = save_lines')
Bram Moolenaar65408f72017-03-07 21:31:27 +0100222 endif
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100223 endif
224endwhile
225
226call add(script, 'let &term = save_term')
227call add(script, 'let &columns = save_columns')
228call add(script, 'let &lines = save_lines')
229
Bram Moolenaare8512d72017-03-07 22:33:32 +0100230call writefile(script, 'opt_test.vim')
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100231
Bram Moolenaar5b3af142017-02-27 22:59:40 +0100232endif
233
Bram Moolenaar2f5463d2017-02-25 20:40:46 +0100234qa!