Mirror of the Vim source from https://github.com/vim/vim
Revision | da9142bd190a5ee0e45536ae4c2913be5bdb02b6 (tree) |
---|---|
Time | 2005-09-21 08:22:24 |
Author | vimboss |
Commiter | vimboss |
updated for version 7.0149
@@ -0,0 +1,391 @@ | ||
1 | +" Vim completion script | |
2 | +" Language: CSS 2.1 | |
3 | +" Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) | |
4 | +" Last Change: 2005 Sep 19 | |
5 | + | |
6 | +function! csscomplete#CompleteCSS(findstart, base) | |
7 | +if a:findstart | |
8 | + " We need whole line to proper checking | |
9 | + return 0 | |
10 | +else | |
11 | + " There are few chars important for context: | |
12 | + " ^ ; : { } /* */ | |
13 | + " Where ^ is start of line and /* */ are comment borders | |
14 | + " Depending on their relative position to cursor we will now what should | |
15 | + " be completed. | |
16 | + " 1. if nearest are ^ or { or ; current word is property | |
17 | + " 2. if : it is value | |
18 | + " 3. if } we are outside of css definitions | |
19 | + " 4. for comments ignoring is be the easiest but assume they are the same | |
20 | + " as 1. | |
21 | + | |
22 | + let line = a:base | |
23 | + let res = [] | |
24 | + let res2 = [] | |
25 | + let borders = {} | |
26 | + | |
27 | + " We need the last occurrence of char so reverse line | |
28 | + let revline = join(reverse(split(line, '.\zs')), '') | |
29 | + let openbrace = stridx(revline, '{') | |
30 | + let closebrace = stridx(revline, '}') | |
31 | + let colon = stridx(revline, ':') | |
32 | + let semicolon = stridx(revline, ';') | |
33 | + let opencomm = stridx(revline, '*/') " Line was reversed | |
34 | + let closecomm = stridx(revline, '/*') " Line was reversed | |
35 | + let style = stridx(revline, '=\s*elyts') " Line was reversed | |
36 | + let atrule = stridx(revline, '@') | |
37 | + | |
38 | + if openbrace > -1 | |
39 | + let borders[openbrace] = "openbrace" | |
40 | + endif | |
41 | + if closebrace > -1 | |
42 | + let borders[closebrace] = "closebrace" | |
43 | + endif | |
44 | + if colon > -1 | |
45 | + let borders[colon] = "colon" | |
46 | + endif | |
47 | + if semicolon > -1 | |
48 | + let borders[semicolon] = "semicolon" | |
49 | + endif | |
50 | + if opencomm > -1 | |
51 | + let borders[opencomm] = "opencomm" | |
52 | + endif | |
53 | + if closecomm > -1 | |
54 | + let borders[closecomm] = "closecomm" | |
55 | + endif | |
56 | + if style > -1 | |
57 | + let borders[style] = "style" | |
58 | + endif | |
59 | + if atrule > -1 | |
60 | + let borders[atrule] = "atrule" | |
61 | + endif | |
62 | + | |
63 | + if len(borders) == 0 || borders[min(keys(borders))] =~ '^\(openbrace\|semicolon\|opencomm\|closecomm\|style\)$' | |
64 | + " Complete properties | |
65 | + | |
66 | + let values = split("azimuth background-attachment background-color background-image background-position background-repeat background border-collapse border-color border-spacing border-style border-top border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width border-bottom-width border-left-width border-width border bottom caption-side clear clip color content counter-increment counter-reset cue-after cue-before cue cursor direction display elevation empty-cells float font-family font-size font-style font-variant font-weight font height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-right margin-left margin-top margin-bottom max-height max-width min-height min-width orphans outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page-break-after page-break-before page-break-inside pause-after pause-before pause pitch-range pitch play-during position quotes richness right speak-header speak-numeral speak-punctuation speak speech-rate stress table-layout text-align text-decoration text-indent text-transform top unicode-bidi vertical-align visibility voice-family volume white-space widows width word-spacing z-index") | |
67 | + | |
68 | + let propbase = matchstr(line, '.\{-}\ze[a-zA-Z-]*$') | |
69 | + let entered_property = matchstr(line, '.\{-}\zs[a-zA-Z-]*$') | |
70 | + | |
71 | + for m in values | |
72 | + if m =~? '^'.entered_property | |
73 | + call add(res, propbase . m.': ') | |
74 | + elseif m =~? entered_property | |
75 | + call add(res2, propbase . m.': ') | |
76 | + endif | |
77 | + endfor | |
78 | + | |
79 | + return res + res2 | |
80 | + | |
81 | + elseif borders[min(keys(borders))] == 'colon' | |
82 | + " Get name of property | |
83 | + let prop = tolower(matchstr(line, '\zs[a-zA-Z-]*\ze\s*:[^:]\{-}$')) | |
84 | + | |
85 | + if prop == 'azimuth' | |
86 | + let values = ["left-side", "far-left", "left", "center-left", "center", "center-right", "right", "far-right", "right-side", "behind", "leftwards", "rightwards"] | |
87 | + elseif prop == 'background-attachment' | |
88 | + let values = ["scroll", "fixed"] | |
89 | + elseif prop == 'background-color' | |
90 | + let values = ["transparent", "rgb(", "#"] | |
91 | + elseif prop == 'background-image' | |
92 | + let values = ["url(", "none"] | |
93 | + elseif prop == 'background-position' | |
94 | + let vals = matchstr(line, '.*:\s*\zs.*') | |
95 | + if vals =~ '^\([a-zA-Z]\+\)\?$' | |
96 | + let values = ["top", "center", "bottom"] | |
97 | + elseif vals =~ '^[a-zA-Z]\+\s\+\([a-zA-Z]\+\)\?$' | |
98 | + let values = ["left", "center", "right"] | |
99 | + else | |
100 | + return [] | |
101 | + endif | |
102 | + elseif prop == 'background-repeat' | |
103 | + let values = ["repeat", "repeat-x", "repeat-y", "no-repeat"] | |
104 | + elseif prop == 'background' | |
105 | + let values = ["url(", "scroll", "fixed", "transparent", "rgb(", "#", "none", "top", "center", "bottom" , "left", "right", "repeat", "repeat-x", "repeat-y", "no-repeat"] | |
106 | + elseif prop == 'border-collapse' | |
107 | + let values = ["collapse", "separate"] | |
108 | + elseif prop == 'border-color' | |
109 | + let values = ["rgb(", "#", "transparent"] | |
110 | + elseif prop == 'border-spacing' | |
111 | + return [] | |
112 | + elseif prop == 'border-style' | |
113 | + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] | |
114 | + elseif prop =~ 'border-\(top\|right\|bottom\|left\)$' | |
115 | + let vals = matchstr(line, '.*:\s*\zs.*') | |
116 | + if vals =~ '^\([a-zA-Z0-9.]\+\)\?$' | |
117 | + let values = ["thin", "thick", "medium"] | |
118 | + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\([a-zA-Z]\+\)\?$' | |
119 | + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] | |
120 | + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\([a-zA-Z(]\+\)\?$' | |
121 | + let values = ["rgb(", "#", "transparent"] | |
122 | + else | |
123 | + return [] | |
124 | + endif | |
125 | + elseif prop =~ 'border-\(top\|right\|bottom\|left\)-color' | |
126 | + let values = ["rgb(", "#", "transparent"] | |
127 | + elseif prop =~ 'border-\(top\|right\|bottom\|left\)-style' | |
128 | + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] | |
129 | + elseif prop =~ 'border-\(top\|right\|bottom\|left\)-width' | |
130 | + let values = ["thin", "thick", "medium"] | |
131 | + elseif prop == 'border-width' | |
132 | + let values = ["thin", "thick", "medium"] | |
133 | + elseif prop == 'border' | |
134 | + let vals = matchstr(line, '.*:\s*\zs.*') | |
135 | + if vals =~ '^\([a-zA-Z0-9.]\+\)\?$' | |
136 | + let values = ["thin", "thick", "medium"] | |
137 | + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+\([a-zA-Z]\+\)\?$' | |
138 | + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] | |
139 | + elseif vals =~ '^[a-zA-Z0-9.]\+\s\+[a-zA-Z]\+\s\+\([a-zA-Z(]\+\)\?$' | |
140 | + let values = ["rgb(", "#", "transparent"] | |
141 | + else | |
142 | + return [] | |
143 | + endif | |
144 | + elseif prop == 'bottom' | |
145 | + let values = ["auto"] | |
146 | + elseif prop == 'caption-side' | |
147 | + let values = ["top", "bottom"] | |
148 | + elseif prop == 'clear' | |
149 | + let values = ["none", "left", "right", "both"] | |
150 | + elseif prop == 'clip' | |
151 | + let values = ["auto", "rect("] | |
152 | + elseif prop == 'color' | |
153 | + let values = ["rgb(", "#"] | |
154 | + elseif prop == 'content' | |
155 | + let values = ["normal", "attr(", "open-quote", "close-quote", "no-open-quote", "no-close-quote"] | |
156 | + elseif prop =~ 'counter-\(increment\|reset\)$' | |
157 | + let values = ["none"] | |
158 | + elseif prop =~ '^\(cue-after\|cue-before\|cue\)$' | |
159 | + let values = ["url(", "none"] | |
160 | + elseif prop == 'cursor' | |
161 | + let values = ["url(", "auto", "crosshair", "default", "pointer", "move", "e-resize", "ne-resize", "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "text", "wait", "help", "progress"] | |
162 | + elseif prop == 'direction' | |
163 | + let values = ["ltr", "rtl"] | |
164 | + elseif prop == 'display' | |
165 | + let values = ["inline", "block", "list-item", "run-in", "inline-block", "table", "inline-table", "table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group", "table-column", "table-cell", "table-caption", "none"] | |
166 | + elseif prop == 'elevation' | |
167 | + let values = ["below", "level", "above", "higher", "lower"] | |
168 | + elseif prop == 'empty-cells' | |
169 | + let values = ["show", "hide"] | |
170 | + elseif prop == 'float' | |
171 | + let values = ["left", "right", "none"] | |
172 | + elseif prop == 'font-family' | |
173 | + let values = ["sans-serif", "serif", "monospace", "cursive", "fantasy"] | |
174 | + elseif prop == 'font-size' | |
175 | + return [] | |
176 | + elseif prop == 'font-style' | |
177 | + let values = ["normal", "italic", "oblique"] | |
178 | + elseif prop == 'font-variant' | |
179 | + let values = ["normal", "small-caps"] | |
180 | + elseif prop == 'font-weight' | |
181 | + let values = ["normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"] | |
182 | + elseif prop == 'font' | |
183 | + let values = ["normal", "italic", "oblique", "small-caps", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "sans-serif", "serif", "monospace", "cursive", "fantasy", "caption", "icon", "menu", "message-box", "small-caption", "status-bar"] | |
184 | + elseif prop =~ '^\(height\|width\)$' | |
185 | + let values = ["auto"] | |
186 | + elseif prop =~ '^\(left\|rigth\)$' | |
187 | + let values = ["auto"] | |
188 | + elseif prop == 'letter-spacing' | |
189 | + let values = ["normal"] | |
190 | + elseif prop == 'line-height' | |
191 | + let values = ["normal"] | |
192 | + elseif prop == 'list-style-image' | |
193 | + let values = ["url(", "none"] | |
194 | + elseif prop == 'list-style-position' | |
195 | + let values = ["inside", "outside"] | |
196 | + elseif prop == 'list-style-type' | |
197 | + let values = ["disc", "circle", "square", "decimal", "decimal-leading-zero", "lower-roman", "upper-roman", "lower-latin", "upper-latin", "none"] | |
198 | + elseif prop == 'list-style' | |
199 | + return [] | |
200 | + elseif prop == 'margin' | |
201 | + let values = ["auto"] | |
202 | + elseif prop =~ 'margin-\(right\|left\|top\|bottom\)$' | |
203 | + let values = ["auto"] | |
204 | + elseif prop == 'max-height' | |
205 | + let values = ["auto"] | |
206 | + elseif prop == 'max-width' | |
207 | + let values = ["none"] | |
208 | + elseif prop == 'min-height' | |
209 | + let values = ["none"] | |
210 | + elseif prop == 'min-width' | |
211 | + let values = ["none"] | |
212 | + elseif prop == 'orphans' | |
213 | + return [] | |
214 | + elseif prop == 'outline-color' | |
215 | + let values = ["rgb(", "#"] | |
216 | + elseif prop == 'outline-style' | |
217 | + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] | |
218 | + elseif prop == 'outline-width' | |
219 | + let values = ["thin", "thick", "medium"] | |
220 | + elseif prop == 'outline' | |
221 | + let vals = matchstr(line, '.*:\s*\zs.*') | |
222 | + if vals =~ '^\([a-zA-Z0-9,()#]\+\)\?$' | |
223 | + let values = ["rgb(", "#"] | |
224 | + elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+\([a-zA-Z]\+\)\?$' | |
225 | + let values = ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"] | |
226 | + elseif vals =~ '^[a-zA-Z0-9,()#]\+\s\+[a-zA-Z]\+\s\+\([a-zA-Z(]\+\)\?$' | |
227 | + let values = ["thin", "thick", "medium"] | |
228 | + else | |
229 | + return [] | |
230 | + endif | |
231 | + elseif prop == 'overflow' | |
232 | + let values = ["visible", "hidden", "scroll", "auto"] | |
233 | + elseif prop == 'padding' | |
234 | + return [] | |
235 | + elseif prop =~ 'padding-\(top\|right\|bottom\|left\)$' | |
236 | + return [] | |
237 | + elseif prop =~ 'page-break-\(after\|before\)$' | |
238 | + let values = ["auto", "always", "avoid", "left", "right"] | |
239 | + elseif prop == 'page-break-inside' | |
240 | + let values = ["auto", "avoid"] | |
241 | + elseif prop =~ 'pause-\(after\|before\)$' | |
242 | + return [] | |
243 | + elseif prop == 'pause' | |
244 | + return [] | |
245 | + elseif prop == 'pitch-range' | |
246 | + return [] | |
247 | + elseif prop == 'pitch' | |
248 | + let values = ["x-low", "low", "medium", "high", "x-high"] | |
249 | + elseif prop == 'play-during' | |
250 | + let values = ["url(", "mix", "repeat", "auto", "none"] | |
251 | + elseif prop == 'position' | |
252 | + let values = ["static", "relative", "absolute", "fixed"] | |
253 | + elseif prop == 'quotes' | |
254 | + let values = ["none"] | |
255 | + elseif prop == 'richness' | |
256 | + return [] | |
257 | + elseif prop == 'speak-header' | |
258 | + let values = ["once", "always"] | |
259 | + elseif prop == 'speak-numeral' | |
260 | + let values = ["digits", "continuous"] | |
261 | + elseif prop == 'speak-punctuation' | |
262 | + let values = ["code", "none"] | |
263 | + elseif prop == 'speak' | |
264 | + let values = ["normal", "none", "spell-out"] | |
265 | + elseif prop == 'speech-rate' | |
266 | + let values = ["x-slow", "slow", "medium", "fast", "x-fast", "faster", "slower"] | |
267 | + elseif prop == 'stress' | |
268 | + return [] | |
269 | + elseif prop == 'table-layout' | |
270 | + let values = ["auto", "fixed"] | |
271 | + elseif prop == 'text-align' | |
272 | + let values = ["left", "right", "center", "justify"] | |
273 | + elseif prop == 'text-decoration' | |
274 | + let values = ["none", "underline", "overline", "line-through", "blink"] | |
275 | + elseif prop == 'text-indent' | |
276 | + return [] | |
277 | + elseif prop == 'text-transform' | |
278 | + let values = ["capitalize", "uppercase", "lowercase", "none"] | |
279 | + elseif prop == 'top' | |
280 | + let values = ["auto"] | |
281 | + elseif prop == 'unicode-bidi' | |
282 | + let values = ["normal", "embed", "bidi-override"] | |
283 | + elseif prop == 'vertical-align' | |
284 | + let values = ["baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom"] | |
285 | + elseif prop == 'visibility' | |
286 | + let values = ["visible", "hidden", "collapse"] | |
287 | + elseif prop == 'voice-family' | |
288 | + return [] | |
289 | + elseif prop == 'volume' | |
290 | + let values = ["silent", "x-soft", "soft", "medium", "loud", "x-loud"] | |
291 | + elseif prop == 'white-space' | |
292 | + let values = ["normal", "pre", "nowrap", "pre-wrap", "pre-line"] | |
293 | + elseif prop == 'widows' | |
294 | + return [] | |
295 | + elseif prop == 'word-spacing' | |
296 | + let values = ["normal"] | |
297 | + elseif prop == 'z-index' | |
298 | + let values = ["auto"] | |
299 | + else | |
300 | + return [] | |
301 | + endif | |
302 | + | |
303 | + " Complete values | |
304 | + let valbase = matchstr(line, '.\{-}\ze[a-zA-Z0-9#,.(_-]*$') | |
305 | + let entered_value = matchstr(line, '.\{-}\zs[a-zA-Z0-9#,.(_-]*$') | |
306 | + | |
307 | + for m in values | |
308 | + if m =~? '^'.entered_value | |
309 | + call add(res, valbase . m) | |
310 | + elseif m =~? entered_value | |
311 | + call add(res2, valbase . m) | |
312 | + endif | |
313 | + endfor | |
314 | + | |
315 | + return res + res2 | |
316 | + | |
317 | + elseif borders[min(keys(borders))] == 'closebrace' | |
318 | + | |
319 | + return [] | |
320 | + | |
321 | + elseif borders[min(keys(borders))] == 'atrule' | |
322 | + | |
323 | + let afterat = matchstr(line, '.*@\zs.*') | |
324 | + | |
325 | + if afterat =~ '\s' | |
326 | + | |
327 | + let atrulename = matchstr(line, '.*@\zs[a-zA-Z-]\+\ze') | |
328 | + | |
329 | + if atrulename == 'media' | |
330 | + let values = ["screen", "tty", "tv", "projection", "handheld", "print", "braille", "aural", "all"] | |
331 | + | |
332 | + let atruleafterbase = matchstr(line, '.*@media\s\+\ze.*$') | |
333 | + let entered_atruleafter = matchstr(line, '.*@media\s\+\zs.*$') | |
334 | + | |
335 | + elseif atrulename == 'import' | |
336 | + let atruleafterbase = matchstr(line, '.*@import\s\+\ze.*$') | |
337 | + let entered_atruleafter = matchstr(line, '.*@import\s\+\zs.*$') | |
338 | + | |
339 | + if entered_atruleafter =~ "^[\"']" | |
340 | + let filestart = matchstr(entered_atruleafter, '^.\zs.*') | |
341 | + let files = split(glob(filestart.'*'), '\n') | |
342 | + let values = map(copy(files), '"\"".v:val') | |
343 | + | |
344 | + elseif entered_atruleafter =~ "^url(" | |
345 | + let filestart = matchstr(entered_atruleafter, "^url([\"']\\?\\zs.*") | |
346 | + let files = split(glob(filestart.'*'), '\n') | |
347 | + let values = map(copy(files), '"url(".v:val') | |
348 | + | |
349 | + else | |
350 | + let values = ['"', 'url('] | |
351 | + | |
352 | + endif | |
353 | + | |
354 | + else | |
355 | + return [] | |
356 | + | |
357 | + endif | |
358 | + | |
359 | + for m in values | |
360 | + if m =~? '^'.entered_atruleafter | |
361 | + call add(res, atruleafterbase . m) | |
362 | + elseif m =~? entered_atruleafter | |
363 | + call add(res2, atruleafterbase . m) | |
364 | + endif | |
365 | + endfor | |
366 | + | |
367 | + return res + res2 | |
368 | + | |
369 | + endif | |
370 | + | |
371 | + let values = ["charset", "page", "media", "import"] | |
372 | + | |
373 | + let atrulebase = matchstr(line, '.*@\ze[a-zA-Z -]*$') | |
374 | + let entered_atrule = matchstr(line, '.*@\zs[a-zA-Z-]*$') | |
375 | + | |
376 | + for m in values | |
377 | + if m =~? '^'.entered_atrule | |
378 | + call add(res, atrulebase . m.' ') | |
379 | + elseif m =~? entered_atrule | |
380 | + call add(res2, atrulebase . m.' ') | |
381 | + endif | |
382 | + endfor | |
383 | + | |
384 | + return res + res2 | |
385 | + | |
386 | + endif | |
387 | + | |
388 | + return [] | |
389 | + | |
390 | + endif | |
391 | +endfunction |
@@ -1,7 +1,7 @@ | ||
1 | 1 | " Vim completion script |
2 | 2 | " Language: XHTML 1.0 Strict |
3 | 3 | " Maintainer: Mikolaj Machowski ( mikmach AT wp DOT pl ) |
4 | -" Last Change: 2005 Sep 15 | |
4 | +" Last Change: 2005 Sep 19 | |
5 | 5 | |
6 | 6 | function! htmlcomplete#CompleteTags(findstart, base) |
7 | 7 | if a:findstart |
@@ -11,26 +11,53 @@ | ||
11 | 11 | while start >= 0 && line[start - 1] !~ '<' |
12 | 12 | let start -= 1 |
13 | 13 | endwhile |
14 | + if start < 0 | |
15 | + let curpos = line('.') | |
16 | + let stylestart = searchpair('<style\>', '', '<\/style\>', "bnW") | |
17 | + let styleend = searchpair('<style\>', '', '<\/style\>', "nW") | |
18 | + if stylestart != 0 && styleend != 0 | |
19 | + if stylestart <= curpos && styleend >= curpos | |
20 | + let b:csscompl = 1 | |
21 | + let start = 0 | |
22 | + endif | |
23 | + endif | |
24 | + endif | |
14 | 25 | return start |
15 | 26 | else |
27 | + " Check if we should do CSS completion inside of <style> tag | |
28 | + if exists("b:csscompl") | |
29 | + unlet! b:csscompl | |
30 | + return csscomplete#CompleteCSS(0, a:base) | |
31 | + endif | |
32 | + if a:base =~ '>' | |
33 | + " Generally if a:base contains > it means we are outside of tag and | |
34 | + " should abandon action - with one exception: <style> span { bo | |
35 | + if a:base =~ 'style[^>]\{-}>[^<]\{-}$' | |
36 | + return csscomplete#CompleteCSS(0, a:base) | |
37 | + else | |
38 | + return [] | |
39 | + endif | |
40 | + endif | |
41 | + | |
16 | 42 | " Set attribute groups |
17 | - let g:coreattrs = ["id", "class", "style", "title"] | |
18 | - let g:i18n = ["lang", "xml:lang", "dir"] | |
19 | - let g:events = ["onclick", "ondblclick", "onmousedown", "onmouseup", "onmousemove", | |
43 | + let coreattrs = ["id", "class", "style", "title"] | |
44 | + let i18n = ["lang", "xml:lang", "dir=\"ltr\" ", "dir=\"rtl\" "] | |
45 | + let events = ["onclick", "ondblclick", "onmousedown", "onmouseup", "onmousemove", | |
20 | 46 | \ "onmouseout", "onkeypress", "onkeydown", "onkeyup"] |
21 | - let g:focus = ["accesskey", "tabindex", "onfocus", "onblur"] | |
22 | - let g:coregroup = g:coreattrs | |
23 | - let g:coregroup = extend(g:coregroup, g:i18n) | |
24 | - let g:coregroup = extend(g:coregroup, g:events) | |
47 | + let focus = ["accesskey", "tabindex", "onfocus", "onblur"] | |
48 | + let coregroup = coreattrs + i18n + events | |
49 | + let res = [] | |
50 | + let res2 = [] | |
25 | 51 | " find tags matching with "a:base" |
26 | - let res = [] | |
27 | 52 | " If a:base contains > it means we are already outside of tag and we |
28 | 53 | " should abandon action |
29 | - if a:base =~ '>' | |
30 | - return [] | |
31 | - endif | |
32 | 54 | " If a:base contains white space it is attribute. |
33 | 55 | " It could be also value of attribute... |
56 | + " We have to get first word to offer | |
57 | + " proper completions | |
58 | + let tag = split(a:base)[0] | |
59 | + " Get last word, it should be attr name | |
60 | + let attr = matchstr(a:base, '.*\s\zs.*') | |
34 | 61 | " Possible situations where any prediction would be difficult: |
35 | 62 | " 1. Events attributes |
36 | 63 | if a:base =~ '\s' |
@@ -40,6 +67,113 @@ | ||
40 | 67 | " Also retrieving class names from current file and linked |
41 | 68 | " stylesheets. |
42 | 69 | if a:base =~ "\\(on[a-z]*\\|style\\|class\\)\\s*=\\s*[\"']" |
70 | + if a:base =~ "class\\s*=\\s*[\"'][a-zA-Z0-9_ -]*$" | |
71 | + " Handle class name completion | |
72 | + " 1. Find lines of <link stylesheet> | |
73 | + " 1a. Check file for @import | |
74 | + " 2. Extract filename(s?) of stylesheet, | |
75 | + call cursor(1,1) | |
76 | + let head = getline(search('<head\>'), search('<\/head>')) | |
77 | + let headjoined = join(copy(head), ' ') | |
78 | + if headjoined =~ '<style' | |
79 | + let stylehead = substitute(headjoined, '+>\*[', ' ', 'g') | |
80 | + let styleheadlines = split(stylehead) | |
81 | + let headclasslines = filter(copy(styleheadlines), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'") | |
82 | + let internal = 1 | |
83 | + else | |
84 | + let internal = 0 | |
85 | + endif | |
86 | + let styletable = [] | |
87 | + let secimportfiles = [] | |
88 | + let filestable = filter(copy(head), "v:val =~ '\\(@import\\|link.*stylesheet\\)'") | |
89 | + for line in filestable | |
90 | + if line =~ "@import" | |
91 | + let styletable += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")] | |
92 | + elseif line =~ "<link" | |
93 | + let styletable += [matchstr(line, "href\\s*=\\s*[\"']\\zs\\f\\+\\ze")] | |
94 | + endif | |
95 | + endfor | |
96 | + for file in filestable | |
97 | + if filereadable(file) | |
98 | + let stylesheet = readfile(file) | |
99 | + let secimport = filter(copy(stylesheet), "v:val =~ '@import'") | |
100 | + if len(secimport) > 0 | |
101 | + for line in secimport | |
102 | + let secimportfiles += [matchstr(line, "import\\s\\+\\(url(\\)\\?[\"']\\?\\zs\\f\\+\\ze")] | |
103 | + endfor | |
104 | + endif | |
105 | + endif | |
106 | + endfor | |
107 | + let cssfiles = styletable + secimportfiles | |
108 | + let classes = [] | |
109 | + for file in cssfiles | |
110 | + if filereadable(file) | |
111 | + let stylesheet = readfile(file) | |
112 | + let stylefile = join(stylesheet) | |
113 | + let stylefile = substitute(stylefile, '+>\*[', ' ', 'g') | |
114 | + let stylesheet = split(stylefile) | |
115 | + let classlines = filter(copy(stylesheet), "v:val =~ '\\([a-zA-Z0-9:]\\+\\)\\?\\.[a-zA-Z0-9_-]\\+'") | |
116 | + endif | |
117 | + " We gathered classes definitions from all external files | |
118 | + let classes += classlines | |
119 | + endfor | |
120 | + if internal == 1 | |
121 | + let classes += headclasslines | |
122 | + endif | |
123 | + let elements = {} | |
124 | + for element in classes | |
125 | + if element =~ '^\.' | |
126 | + let class = matchstr(element, '^\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze') | |
127 | + let class = substitute(class, ':.*', '', '') | |
128 | + if has_key(elements, "common") | |
129 | + let elements["common"] .= " ".class | |
130 | + else | |
131 | + let elements["common"] = class | |
132 | + endif | |
133 | + else | |
134 | + let class = matchstr(element, '[a-zA-Z1-6]*\.\zs[a-zA-Z][a-zA-Z0-9_-]*\ze') | |
135 | + let tagname = tolower(matchstr(element, '[a-zA-Z1-6]*\ze.')) | |
136 | + if tagname != '' | |
137 | + if has_key(elements, tagname) | |
138 | + let elements[tagname] .= " ".class | |
139 | + else | |
140 | + let elements[tagname] = class | |
141 | + endif | |
142 | + endif | |
143 | + endif | |
144 | + endfor | |
145 | + | |
146 | + if has_key(elements, tag) && has_key(elements, "common") | |
147 | + let values = split(elements[tag]." ".elements["common"]) | |
148 | + elseif has_key(elements, tag) && !has_key(elements, "common") | |
149 | + let values = split(elements[tag]) | |
150 | + elseif !has_key(elements, tag) && has_key(elements, "common") | |
151 | + let values = split(elements["common"]) | |
152 | + else | |
153 | + return [] | |
154 | + endif | |
155 | + | |
156 | + " We need special version of sbase | |
157 | + let classbase = matchstr(a:base, ".*[\"']") | |
158 | + let classquote = matchstr(classbase, '.$') | |
159 | + | |
160 | + | |
161 | + let entered_class = matchstr(attr, ".*=\\s*[\"']\\zs.*") | |
162 | + | |
163 | + for m in sort(values) | |
164 | + if m =~? '^'.entered_class | |
165 | + call add(res, classbase . m . classquote . ' ') | |
166 | + elseif m =~? entered_class | |
167 | + call add(res2, classbase . m . classquote . ' ') | |
168 | + endif | |
169 | + endfor | |
170 | + | |
171 | + return res + res2 | |
172 | + | |
173 | + elseif a:base =~ "style\\s*=\\s*[\"'][^\"']*$" | |
174 | + return csscomplete#CompleteCSS(0, a:base) | |
175 | + | |
176 | + endif | |
43 | 177 | let stripbase = matchstr(a:base, ".*\\(on[a-z]*\\|style\\|class\\)\\s*=\\s*[\"']\\zs.*") |
44 | 178 | " Now we have a:base stripped from all chars up to style/class. |
45 | 179 | " It may fail with some strange style value combinations. |
@@ -47,11 +181,6 @@ | ||
47 | 181 | return [] |
48 | 182 | endif |
49 | 183 | endif |
50 | - " We have to get first word to offer | |
51 | - " proper attributes. | |
52 | - let tag = split(a:base)[0] | |
53 | - " Get last word, it should be attr name | |
54 | - let attr = matchstr(a:base, '.*\s\zs.*') | |
55 | 184 | " If attr contains =\s*[\"'] we catched value of attribute |
56 | 185 | if attr =~ "=\s*[\"']" |
57 | 186 | " Let do attribute specific completion |
@@ -97,7 +226,7 @@ | ||
97 | 226 | endif |
98 | 227 | elseif attrname == 'type' |
99 | 228 | if a:base =~ '^input' |
100 | - let values = ["input-text", "password", "checkbox", "radio", "submit", "reset", "input-file", "hidden", "input-image", "input-button"] | |
229 | + let values = ["text", "password", "checkbox", "radio", "submit", "reset", "file", "hidden", "image", "button"] | |
101 | 230 | elseif a:base =~ '^button' |
102 | 231 | let values = ["button", "submit", "reset"] |
103 | 232 | endif |
@@ -111,128 +240,114 @@ | ||
111 | 240 | |
112 | 241 | " We need special version of sbase |
113 | 242 | let attrbase = matchstr(a:base, ".*[\"']") |
243 | + let attrquote = matchstr(attrbase, '.$') | |
114 | 244 | |
115 | 245 | for m in values |
116 | - if m =~ entered_value | |
117 | - call add(res, attrbase . m . '" ') | |
246 | + " This if is needed to not offer all completions as-is | |
247 | + " alphabetically but sort them. Those beginning with entered | |
248 | + " part will be as first choices | |
249 | + if m =~ '^'.entered_value | |
250 | + call add(res, attrbase . m . attrquote.' ') | |
251 | + elseif m =~ entered_value | |
252 | + call add(res2, attrbase . m . attrquote.' ') | |
118 | 253 | endif |
119 | 254 | endfor |
255 | + | |
256 | + return res + res2 | |
257 | + | |
120 | 258 | endif |
121 | 259 | " Shorten a:base to not include last word |
122 | 260 | let sbase = matchstr(a:base, '.*\ze\s.*') |
123 | 261 | if tag =~ '^\(abbr\|acronym\|b\|bdo\|big\|caption\|cite\|code\|dd\|dfn\|div\|dl\|dt\|em\|fieldset\|h\d\|kbd\|li\|noscript\|ol\|p\|samp\|small\|span\|strong\|sub\|sup\|tt\|ul\|var\)$' |
124 | - let attrs = g:coregroup | |
262 | + let attrs = coregroup | |
125 | 263 | elseif tag == 'a' |
126 | - let tagspec = ["charset", "type", "name", "href", "hreflang", "rel", "rev", "shape", "coords"] | |
127 | - let attrs = extend(tagspec, g:coregroup) | |
128 | - let attrs = extend(attrs, g:focus) | |
264 | + let attrs = coregroup + focus + ["charset", "type", "name", "href", "hreflang", "rel", "rev", "shape", "coords"] | |
129 | 265 | elseif tag == 'area' |
130 | - let attrs = g:coregroup | |
266 | + let attrs = coregroup | |
131 | 267 | elseif tag == 'base' |
132 | 268 | let attrs = ["href", "id"] |
133 | 269 | elseif tag == 'blockquote' |
134 | - let attrs = g:coregroup | |
135 | - let attrs = extend(attrs, ["cite"]) | |
270 | + let attrs = coregroup + ["cite"] | |
136 | 271 | elseif tag == 'body' |
137 | - let attrs = g:coregroup | |
138 | - let attrs = extend(attrs, ["onload", "onunload"]) | |
272 | + let attrs = coregroup + ["onload", "onunload"] | |
139 | 273 | elseif tag == 'br' |
140 | - let attrs = g:coreattrs | |
274 | + let attrs = coreattrs | |
141 | 275 | elseif tag == 'button' |
142 | - let attrs = g:coreattrs | |
143 | - let attrs = extend(attrs, g:focus) | |
144 | - let attrs = extend(attrs, ["name", "value", "type"]) | |
276 | + let attrs = coreattrs + focus + ["name", "value", "type"] | |
145 | 277 | elseif tag == '^\(col\|colgroup\)$' |
146 | - let attrs = g:coreattrs | |
147 | - let attrs = extend(attrs, ["span", "width", "align", "char", "charoff", "valign"]) | |
278 | + let attrs = coreattrs + ["span", "width", "align", "char", "charoff", "valign"] | |
148 | 279 | elseif tag =~ '^\(del\|ins\)$' |
149 | - let attrs = g:coreattrs | |
150 | - let attrs = extend(attrs, ["cite", "datetime"]) | |
280 | + let attrs = coreattrs + ["cite", "datetime"] | |
151 | 281 | elseif tag == 'form' |
152 | - let attrs = g:coreattrs | |
153 | - let attrs = extend(attrs, ["action", "method", "enctype", "onsubmit", "onreset", "accept", "accept-charset"]) | |
282 | + let attrs = coreattrs + ["action", "method=\"get\" ", "method=\"post\" ", "enctype", "onsubmit", "onreset", "accept", "accept-charset"] | |
154 | 283 | elseif tag == 'head' |
155 | - let attrs = g:i18n | |
156 | - let attrs = extend(attrs, ["id", "profile"]) | |
284 | + let attrs = i18n + ["id", "profile"] | |
157 | 285 | elseif tag == 'html' |
158 | - let attrs = g:i18n | |
159 | - let attrs = extend(attrs, ["id", "xmlns"]) | |
286 | + let attrs = i18n + ["id", "xmlns"] | |
160 | 287 | elseif tag == 'img' |
161 | - let attrs = g:coreattrs | |
162 | - let attrs = extend(attrs, ["src", "alt", "longdesc", "height", "width", "usemap", "ismap"]) | |
288 | + let attrs = coreattrs + ["src", "alt", "longdesc", "height", "width", "usemap", "ismap"] | |
163 | 289 | elseif tag == 'input' |
164 | - let attrs = g:coreattrs | |
165 | - let attrs = extend(attrs, g:focus) | |
166 | - let attrs = extend(attrs, ["type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "onselect", "onchange", "accept"]) | |
290 | + let attrs = coreattrs + focus + ["type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "onselect", "onchange", "accept"] | |
167 | 291 | elseif tag == 'label' |
168 | - let attrs = g:coreattrs | |
169 | - let attrs = extend(attrs, ["for", "accesskey", "onfocus", "onblur"]) | |
292 | + let attrs = coreattrs + ["for", "accesskey", "onfocus", "onblur"] | |
170 | 293 | elseif tag == 'legend' |
171 | - let attrs = g:coreattrs | |
172 | - let attrs = extend(attrs, ["accesskey"]) | |
294 | + let attrs = coreattrs + ["accesskey"] | |
173 | 295 | elseif tag == 'link' |
174 | - let attrs = g:coreattrs | |
175 | - let attrs = extend(attrs, ["charset", "href", "hreflang", "type", "rel", "rev", "media"]) | |
296 | + let attrs = coreattrs + ["charset", "href", "hreflang", "type", "rel", "rev", "media"] | |
176 | 297 | elseif tag == 'map' |
177 | - let attrs = g:i18n | |
178 | - let attrs = extend(attrs, g:events) | |
179 | - let attrs = extend(attrs, ["id", "class", "style", "title", "name"]) | |
298 | + let attrs = i18n + events + ["id", "class", "style", "title", "name"] | |
180 | 299 | elseif tag == 'meta' |
181 | - let attrs = g:i18n | |
182 | - let attrs = extend(attrs, ["id", "http-equiv", "content", "scheme", "name"]) | |
300 | + let attrs = i18n + ["id", "http-equiv", "content", "scheme", "name"] | |
183 | 301 | elseif tag == 'title' |
184 | - let attrs = g:i18n | |
185 | - let attrs = extend(attrs, ["id"]) | |
302 | + let attrs = i18n + ["id"] | |
186 | 303 | elseif tag == 'object' |
187 | - let attrs = g:coreattrs | |
188 | - let attrs = extend(attrs, ["declare", "classid", "codebase", "data", "type", "codetype", "archive", "standby", "height", "width", "usemap", "name", "tabindex"]) | |
304 | + let attrs = coreattrs + ["declare", "classid", "codebase", "data", "type", "codetype", "archive", "standby", "height", "width", "usemap", "name", "tabindex"] | |
189 | 305 | elseif tag == 'optgroup' |
190 | - let attrs = g:coreattrs | |
191 | - let attrs = extend(attrs, ["disbled", "label"]) | |
306 | + let attrs = coreattrs + ["disbled", "label"] | |
192 | 307 | elseif tag == 'option' |
193 | - let attrs = g:coreattrs | |
194 | - let attrs = extend(attrs, ["disbled", "selected", "value", "label"]) | |
308 | + let attrs = coreattrs + ["disbled", "selected", "value", "label"] | |
195 | 309 | elseif tag == 'param' |
196 | 310 | let attrs = ["id", "name", "value", "valuetype", "type"] |
197 | 311 | elseif tag == 'pre' |
198 | - let attrs = g:coreattrs | |
199 | - let attrs = extend(attrs, ["xml:space"]) | |
312 | + let attrs = coreattrs + ["xml:space"] | |
200 | 313 | elseif tag == 'q' |
201 | - let attrs = g:coreattrs | |
202 | - let attrs = extend(attrs, ["cite"]) | |
314 | + let attrs = coreattrs + ["cite"] | |
203 | 315 | elseif tag == 'script' |
204 | 316 | let attrs = ["id", "charset", "type", "src", "defer", "xml:space"] |
205 | 317 | elseif tag == 'select' |
206 | - let attrs = g:coreattrs | |
207 | - let attrs = extend(attrs, ["name", "size", "multiple", "disabled", "tabindex", "onfocus", "onblur", "onchange"]) | |
318 | + let attrs = coreattrs + ["name", "size", "multiple", "disabled", "tabindex", "onfocus", "onblur", "onchange"] | |
208 | 319 | elseif tag == 'style' |
209 | - let attrs = g:coreattrs | |
210 | - let attrs = extend(attrs, ["id", "type", "media", "title", "xml:space"]) | |
320 | + let attrs = coreattrs + ["id", "type", "media", "title", "xml:space"] | |
211 | 321 | elseif tag == 'table' |
212 | - let attrs = g:coreattrs | |
213 | - let attrs = extend(attrs, ["summary", "width", "border", "frame", "rules" "cellspacing", "cellpadding"]) | |
322 | + let attrs = coreattrs + ["summary", "width", "border", "frame", "rules", "cellspacing", "cellpadding"] | |
214 | 323 | elseif tag =~ '^\(thead\|tfoot\|tbody\|tr\)$' |
215 | - let attrs = g:coreattrs | |
216 | - let attrs = extend(attrs, ["align", "char", "charoff", "valign"]) | |
324 | + let attrs = coreattrs + ["align", "char", "charoff", "valign"] | |
217 | 325 | elseif tag == 'textarea' |
218 | - let attrs = g:coreattrs | |
219 | - let attrs = extend(attrs, g:focus) | |
220 | - let attrs = extend(attrs, ["name", "rows", "cols", "disabled", "readonly", "onselect", "onchange"]) | |
326 | + let attrs = coreattrs + focus + ["name", "rows", "cols", "disabled", "readonly", "onselect", "onchange"] | |
221 | 327 | elseif tag =~ '^\(th\|td\)$' |
222 | - let attrs = g:coreattrs | |
223 | - let attrs = extend(attrs, ["abbr", "headers", "scope", "rowspan", "colspan", "align", "char", "charoff", "valign"]) | |
328 | + let attrs = coreattrs + ["abbr", "headers", "scope", "rowspan", "colspan", "align", "char", "charoff", "valign"] | |
329 | + else | |
330 | + return [] | |
224 | 331 | endif |
225 | 332 | |
226 | 333 | for m in sort(attrs) |
227 | - if m =~ attr | |
228 | - if m =~ '^\(ismap\|defer\|declare\|nohref\|checked\|disabled\|selected\|readonly\)$' | |
334 | + if m =~ '^'.attr | |
335 | + if m =~ '^\(ismap\|defer\|declare\|nohref\|checked\|disabled\|selected\|readonly\)$' || m =~ '=' | |
229 | 336 | call add(res, sbase.' '.m) |
230 | 337 | else |
231 | 338 | call add(res, sbase.' '.m.'="') |
232 | 339 | endif |
340 | + elseif m =~ attr | |
341 | + if m =~ '^\(ismap\|defer\|declare\|nohref\|checked\|disabled\|selected\|readonly\)$' || m =~ '=' | |
342 | + call add(res2, sbase.' '.m) | |
343 | + else | |
344 | + call add(res2, sbase.' '.m.'="') | |
345 | + endif | |
233 | 346 | endif |
234 | 347 | endfor |
235 | - return res | |
348 | + | |
349 | + return res + res2 | |
350 | + | |
236 | 351 | endif |
237 | 352 | " Close tag |
238 | 353 | let b:unaryTagsStack = "base meta link hr br param img area input col" |
@@ -258,17 +373,17 @@ | ||
258 | 373 | elseif opentag == 'pre' |
259 | 374 | let tags = split("a tt i b big small br span bdo map ".phrase." ".miscinline." ".inlineforms) |
260 | 375 | elseif opentag == 'html' |
261 | - let tags = split("head body") | |
376 | + let tags = ["head", "body"] | |
262 | 377 | elseif opentag == 'legend' |
263 | 378 | let tags = split(inline." ".miscinline) |
264 | 379 | elseif opentag == 'head' |
265 | - let tags = split("title base scipt style meta link object") | |
380 | + let tags = ["title", "base", "scipt", "style", "meta", "link", "object"] | |
266 | 381 | elseif opentag =~ '^\(noscript\|body\|blockquote\)$' |
267 | 382 | let tags = split("form ".block." ".misc) |
268 | 383 | elseif opentag =~ '^\(ul\|ol\)$' |
269 | 384 | let tags = ["li"] |
270 | 385 | elseif opentag == 'dl' |
271 | - let tags = split("dt dd") | |
386 | + let tags = ["dt", "dd"] | |
272 | 387 | elseif opentag =~ '^\(ins\|del\|th\|td\|dd\|div\|li\)$' |
273 | 388 | let tags = split("form ".block." ".inline." ".misc) |
274 | 389 | elseif opentag == 'object' |
@@ -280,30 +395,34 @@ | ||
280 | 395 | elseif opentag == 'form' |
281 | 396 | let tags = split(block." ".misc) |
282 | 397 | elseif opentag == 'select' |
283 | - let tags = split("optgroup option") | |
398 | + let tags = ["optgroup", "option"] | |
284 | 399 | elseif opentag == 'optgroup' |
285 | 400 | let tags = ["option"] |
286 | 401 | elseif opentag == 'colgroup' |
287 | 402 | let tags = ["col"] |
288 | 403 | elseif opentag == '^\(textarea\|option\|script\|style\|title\)$' |
289 | - let tags = [] | |
404 | + let tags = ['empty'] | |
290 | 405 | elseif opentag == 'button' |
291 | - let tags = split("p h1 h2 h3 h4 h5 h6 div ul ol dl table") | |
292 | - elseif opentag =~ '^\(thead\|tfoot\|tbody)$' | |
406 | + let tags = ["p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "ul", "ol", "dl", "table"] | |
407 | + elseif opentag =~ '^\(thead\|tfoot\|tbody\)$' | |
293 | 408 | let tags = ["tr"] |
294 | 409 | elseif opentag == 'tr' |
295 | - let tags = split("th td") | |
410 | + let tags = ["th", "td"] | |
296 | 411 | elseif opentag == 'table' |
297 | - let tags = split("caption col colgroup thead tfoot tbody tr") | |
412 | + let tags = ["caption", "col", "colgroup", "thead", "tfoot", "tbody", "tr"] | |
413 | + else | |
414 | + return [] | |
298 | 415 | endif |
299 | 416 | |
300 | 417 | for m in tags |
301 | - if m =~ a:base | |
418 | + if m =~ '^'.a:base | |
302 | 419 | call add(res, m) |
420 | + elseif m =~ a:base | |
421 | + call add(res2, m) | |
303 | 422 | endif |
304 | 423 | endfor |
305 | 424 | |
306 | - return res | |
425 | + return res + res2 | |
307 | 426 | |
308 | 427 | endif |
309 | 428 | endfunction |
@@ -316,10 +435,10 @@ | ||
316 | 435 | " Version: 0.9.1 |
317 | 436 | |
318 | 437 | function! htmlcomplete#GetLastOpenTag(unaryTagsStack) |
319 | - let linenum=line(".") | |
320 | - let lineend=col(".") - 1 " start: cursor position | |
438 | + let linenum=line('.') | |
439 | + let lineend=col('.') - 1 " start: cursor position | |
321 | 440 | let first=1 " flag for first line searched |
322 | - let b:TagStack="" " main stack of tags | |
441 | + let b:TagStack='' " main stack of tags | |
323 | 442 | let startInComment=s:InComment() |
324 | 443 | |
325 | 444 | let tagpat='</\=\(\k\|[-:]\)\+\|/>' |
@@ -330,7 +449,7 @@ | ||
330 | 449 | else |
331 | 450 | let lineend=strlen(line) |
332 | 451 | endif |
333 | - let b:lineTagStack="" | |
452 | + let b:lineTagStack='' | |
334 | 453 | let mpos=0 |
335 | 454 | let b:TagCol=0 |
336 | 455 | while (mpos > -1) |
@@ -339,46 +458,45 @@ | ||
339 | 458 | let b:TagCol=b:TagCol+mpos |
340 | 459 | let tag=matchstr(line,tagpat) |
341 | 460 | |
342 | - if exists("b:closetag_disable_synID") || startInComment==s:InCommentAt(linenum, b:TagCol) | |
461 | + if exists('b:closetag_disable_synID') || startInComment==s:InCommentAt(linenum, b:TagCol) | |
343 | 462 | let b:TagLine=linenum |
344 | - call s:Push(matchstr(tag,'[^<>]\+'),"b:lineTagStack") | |
463 | + call s:Push(matchstr(tag,'[^<>]\+'),'b:lineTagStack') | |
345 | 464 | endif |
346 | 465 | let lineend=lineend-mpos |
347 | 466 | let line=strpart(line,mpos,lineend) |
348 | 467 | endif |
349 | 468 | endwhile |
350 | - while (!s:EmptystackP("b:lineTagStack")) | |
351 | - let tag=s:Pop("b:lineTagStack") | |
352 | - if match(tag, "^/") == 0 "found end tag | |
353 | - call s:Push(tag,"b:TagStack") | |
354 | - elseif s:EmptystackP("b:TagStack") && !s:Instack(tag, a:unaryTagsStack) "found unclosed tag | |
469 | + while (!s:EmptystackP('b:lineTagStack')) | |
470 | + let tag=s:Pop('b:lineTagStack') | |
471 | + if match(tag, '^/') == 0 "found end tag | |
472 | + call s:Push(tag,'b:TagStack') | |
473 | + elseif s:EmptystackP('b:TagStack') && !s:Instack(tag, a:unaryTagsStack) "found unclosed tag | |
355 | 474 | return tag |
356 | 475 | else |
357 | - let endtag=s:Peekstack("b:TagStack") | |
358 | - if endtag == "/".tag || endtag == "/" | |
359 | - call s:Pop("b:TagStack") "found a open/close tag pair | |
360 | - elseif !s:Instack(tag, a:unaryTagsStack) "we have a mismatch error | |
361 | - return "" | |
476 | + let endtag=s:Peekstack('b:TagStack') | |
477 | + if endtag == '/'.tag || endtag == '/' | |
478 | + call s:Pop('b:TagStack') "found a open/close tag pair | |
479 | + elseif !s:Instack(tag, a:unaryTagsStack) "we have a mismatch error | |
480 | + return '' | |
481 | + endif | |
362 | 482 | endif |
363 | - endif | |
483 | + endwhile | |
484 | + let linenum=linenum-1 | let first=0 | |
364 | 485 | endwhile |
365 | - let linenum=linenum-1 | let first=0 | |
366 | -endwhile | |
367 | -return "" | |
486 | +return '' | |
368 | 487 | endfunction |
369 | 488 | |
370 | 489 | function! s:InComment() |
371 | - return synIDattr(synID(line("."), col("."), 0), "name") =~ 'Comment' | |
490 | + return synIDattr(synID(line('.'), col('.'), 0), 'name') =~ 'Comment' | |
372 | 491 | endfunction |
373 | 492 | |
374 | 493 | function! s:InCommentAt(line, col) |
375 | - return synIDattr(synID(a:line, a:col, 0), "name") =~ 'Comment' | |
494 | + return synIDattr(synID(a:line, a:col, 0), 'name') =~ 'Comment' | |
376 | 495 | endfunction |
377 | 496 | |
378 | - | |
379 | 497 | function! s:SetKeywords() |
380 | 498 | let g:IsKeywordBak=&iskeyword |
381 | - let &iskeyword="33-255" | |
499 | + let &iskeyword='33-255' | |
382 | 500 | endfunction |
383 | 501 | |
384 | 502 | function! s:RestoreKeywords() |
@@ -387,15 +505,15 @@ | ||
387 | 505 | |
388 | 506 | function! s:Push(el, sname) |
389 | 507 | if !s:EmptystackP(a:sname) |
390 | - exe "let ".a:sname."=a:el.' '.".a:sname | |
508 | + exe 'let '.a:sname."=a:el.' '.".a:sname | |
391 | 509 | else |
392 | - exe "let ".a:sname."=a:el" | |
510 | + exe 'let '.a:sname.'=a:el' | |
393 | 511 | endif |
394 | 512 | endfunction |
395 | 513 | |
396 | 514 | function! s:EmptystackP(sname) |
397 | - exe "let stack=".a:sname | |
398 | - if match(stack,"^ *$") == 0 | |
515 | + exe 'let stack='.a:sname | |
516 | + if match(stack,'^ *$') == 0 | |
399 | 517 | return 1 |
400 | 518 | else |
401 | 519 | return 0 |
@@ -403,9 +521,9 @@ | ||
403 | 521 | endfunction |
404 | 522 | |
405 | 523 | function! s:Instack(el, sname) |
406 | - exe "let stack=".a:sname | |
524 | + exe 'let stack='.a:sname | |
407 | 525 | call s:SetKeywords() |
408 | - let m=match(stack, "\\<".a:el."\\>") | |
526 | + let m=match(stack, '\<'.a:el.'\>') | |
409 | 527 | call s:RestoreKeywords() |
410 | 528 | if m < 0 |
411 | 529 | return 0 |
@@ -416,25 +534,25 @@ | ||
416 | 534 | |
417 | 535 | function! s:Peekstack(sname) |
418 | 536 | call s:SetKeywords() |
419 | - exe "let stack=".a:sname | |
420 | - let top=matchstr(stack, "\\<.\\{-1,}\\>") | |
537 | + exe 'let stack='.a:sname | |
538 | + let top=matchstr(stack, '\<.\{-1,}\>') | |
421 | 539 | call s:RestoreKeywords() |
422 | 540 | return top |
423 | 541 | endfunction |
424 | 542 | |
425 | 543 | function! s:Pop(sname) |
426 | 544 | if s:EmptystackP(a:sname) |
427 | - return "" | |
545 | + return '' | |
428 | 546 | endif |
429 | - exe "let stack=".a:sname | |
547 | + exe 'let stack='.a:sname | |
430 | 548 | call s:SetKeywords() |
431 | - let loc=matchend(stack,"\\<.\\{-1,}\\>") | |
432 | - exe "let ".a:sname."=strpart(stack, loc+1, strlen(stack))" | |
433 | - let top=strpart(stack, match(stack, "\\<"), loc) | |
549 | + let loc=matchend(stack,'\<.\{-1,}\>') | |
550 | + exe 'let '.a:sname.'=strpart(stack, loc+1, strlen(stack))' | |
551 | + let top=strpart(stack, match(stack, '\<'), loc) | |
434 | 552 | call s:RestoreKeywords() |
435 | 553 | return top |
436 | 554 | endfunction |
437 | 555 | |
438 | 556 | function! s:Clearstack(sname) |
439 | - exe "let ".a:sname."=''" | |
557 | + exe 'let '.a:sname."=''" | |
440 | 558 | endfunction |
@@ -1,4 +1,4 @@ | ||
1 | -*cmdline.txt* For Vim version 7.0aa. Last change: 2005 Jul 05 | |
1 | +*cmdline.txt* For Vim version 7.0aa. Last change: 2005 Sep 17 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -153,6 +153,7 @@ | ||
153 | 153 | *c_CTRL-R_=* |
154 | 154 | '=' the expression register: you are prompted to |
155 | 155 | enter an expression (see |expression|) |
156 | + (doesn't work at the expression prompt) | |
156 | 157 | See |registers| about registers. {not in Vi} |
157 | 158 | Implementation detail: When using the |expression| register |
158 | 159 | and invoking setcmdpos(), this sets the position before |
@@ -191,7 +192,8 @@ | ||
191 | 192 | to finish it. It's most useful in mappings though. See |
192 | 193 | |expression|. |
193 | 194 | See |c_CTRL-R_=| for inserting the result of an expression. |
194 | - Useful functions are |getcmdline()| and |getcmdpos()|. | |
195 | + Useful functions are |getcmdtype()|, |getcmdline()| and | |
196 | + |getcmdpos()|. | |
195 | 197 | The cursor position is unchanged, except when the cursor was |
196 | 198 | at the end of the line, then it stays at the end. |
197 | 199 | |setcmdpos()| can be used to set the cursor position. |
@@ -203,7 +205,9 @@ | ||
203 | 205 | :call setcmdpos(strlen(cmd)) |
204 | 206 | :return cmd |
205 | 207 | :endfunc |
206 | -< | |
208 | +< This doesn't work recursively, thus not when already editing | |
209 | + an expression. | |
210 | + | |
207 | 211 | *c_CTRL-Y* |
208 | 212 | CTRL-Y When there is a modeless selection, copy the selection into |
209 | 213 | the clipboard. |modeless-selection| |
@@ -1,4 +1,4 @@ | ||
1 | -*eval.txt* For Vim version 7.0aa. Last change: 2005 Sep 15 | |
1 | +*eval.txt* For Vim version 7.0aa. Last change: 2005 Sep 20 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -1520,6 +1520,7 @@ | ||
1520 | 1520 | getbufvar( {expr}, {varname}) variable {varname} in buffer {expr} |
1521 | 1521 | getcmdline() String return the current command-line |
1522 | 1522 | getcmdpos() Number return cursor position in command-line |
1523 | +getcmdtype() String return the current command-line type | |
1523 | 1524 | getcwd() String the current working directory |
1524 | 1525 | getfperm( {fname}) String file permissions of file {fname} |
1525 | 1526 | getfsize( {fname}) Number size in bytes of file {fname} |
@@ -1550,7 +1551,8 @@ | ||
1550 | 1551 | indent( {lnum}) Number indent of line {lnum} |
1551 | 1552 | index( {list}, {expr} [, {start} [, {ic}]]) |
1552 | 1553 | Number index in {list} where {expr} appears |
1553 | -input( {prompt} [, {text}]) String get input from the user | |
1554 | +input( {prompt} [, {text} [, {completion}]]) | |
1555 | + String get input from the user | |
1554 | 1556 | inputdialog( {p} [, {t} [, {c}]]) String like input() but in a GUI dialog |
1555 | 1557 | inputrestore() Number restore typeahead |
1556 | 1558 | inputsave() Number save and clear typeahead |
@@ -2533,14 +2535,27 @@ | ||
2533 | 2535 | |c_CTRL-R_=|. |
2534 | 2536 | Example: > |
2535 | 2537 | :cmap <F7> <C-\>eescape(getcmdline(), ' \')<CR> |
2536 | -< Also see |getcmdpos()| and |setcmdpos()|. | |
2538 | +< Also see |getcmdtype()|, |getcmdpos()| and |setcmdpos()|. | |
2537 | 2539 | |
2538 | 2540 | getcmdpos() *getcmdpos()* |
2539 | 2541 | Return the position of the cursor in the command line as a |
2540 | 2542 | byte count. The first column is 1. |
2541 | 2543 | Only works when editing the command line, thus requires use of |
2542 | 2544 | |c_CTRL-\_e| or |c_CTRL-R_=|. Returns 0 otherwise. |
2543 | - Also see |setcmdpos()| and |getcmdline()|. | |
2545 | + Also see |getcmdtype()|, |setcmdpos()| and |getcmdline()|. | |
2546 | + | |
2547 | +getcmdtype() *getcmdtype()* | |
2548 | + Return the current command-line type. Possible return values | |
2549 | + are: | |
2550 | + / Search forward command | |
2551 | + ? Search backward command | |
2552 | + : Ex-command mode | |
2553 | + @ Input mode | |
2554 | + > Debug mode | |
2555 | + Only works when editing the command line, thus requires use of | |
2556 | + |c_CTRL-\_e| or |c_CTRL-R_=|. Returns an empty string | |
2557 | + otherwise. | |
2558 | + Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|. | |
2544 | 2559 | |
2545 | 2560 | *getcwd()* |
2546 | 2561 | getcwd() The result is a String, which is the name of the current |
@@ -2910,19 +2925,34 @@ | ||
2910 | 2925 | :if index(numbers, 123) >= 0 |
2911 | 2926 | |
2912 | 2927 | |
2913 | -input({prompt} [, {text}]) *input()* | |
2928 | +input({prompt} [, {text} [, {completion}]]) *input()* | |
2914 | 2929 | The result is a String, which is whatever the user typed on |
2915 | 2930 | the command-line. The parameter is either a prompt string, or |
2916 | 2931 | a blank string (for no prompt). A '\n' can be used in the |
2917 | - prompt to start a new line. The highlighting set with | |
2918 | - |:echohl| is used for the prompt. The input is entered just | |
2919 | - like a command-line, with the same editing commands and | |
2920 | - mappings. There is a separate history for lines typed for | |
2921 | - input(). | |
2932 | + prompt to start a new line. | |
2933 | + The highlighting set with |:echohl| is used for the prompt. | |
2934 | + The input is entered just like a command-line, with the same | |
2935 | + editing commands and mappings. There is a separate history | |
2936 | + for lines typed for input(). | |
2937 | + Example: > | |
2938 | + :if input("Coffee or beer? ") == "beer" | |
2939 | + : echo "Cheers!" | |
2940 | + :endif | |
2941 | +< | |
2922 | 2942 | If the optional {text} is present, this is used for the |
2923 | - default reply, as if the user typed this. | |
2924 | - NOTE: This must not be used in a startup file, for the | |
2925 | - versions that only run in GUI mode (e.g., the Win32 GUI). | |
2943 | + default reply, as if the user typed this. Example: > | |
2944 | + :let color = input("Color? ", "white") | |
2945 | + | |
2946 | +< The optional {completion} argument specifies the type of | |
2947 | + completion supported for the input. Without it completion is | |
2948 | + not performed. The supported completion types are the same as | |
2949 | + that can be supplied to a user-defined command using the | |
2950 | + "-complete=" argument. Refer to |:command-completion| for | |
2951 | + more information. Example: > | |
2952 | + let fname = input("File: ", "", "file") | |
2953 | +< | |
2954 | + NOTE: This function must not be used in a startup file, for | |
2955 | + the versions that only run in GUI mode (e.g., the Win32 GUI). | |
2926 | 2956 | Note: When input() is called from within a mapping it will |
2927 | 2957 | consume remaining characters from that mapping, because a |
2928 | 2958 | mapping is handled like the characters were typed. |
@@ -2931,13 +2961,7 @@ | ||
2931 | 2961 | that further characters follow in the mapping, e.g., by using |
2932 | 2962 | |:execute| or |:normal|. |
2933 | 2963 | |
2934 | - Example: > | |
2935 | - :if input("Coffee or beer? ") == "beer" | |
2936 | - : echo "Cheers!" | |
2937 | - :endif | |
2938 | -< Example with default text: > | |
2939 | - :let color = input("Color? ", "white") | |
2940 | -< Example with a mapping: > | |
2964 | + Example with a mapping: > | |
2941 | 2965 | :nmap \x :call GetFoo()<CR>:exe "/" . Foo<CR> |
2942 | 2966 | :function GetFoo() |
2943 | 2967 | : call inputsave() |
@@ -2957,6 +2981,7 @@ | ||
2957 | 2981 | omitted an empty string is returned. |
2958 | 2982 | Hitting <Enter> works like pressing the OK button. Hitting |
2959 | 2983 | <Esc> works like pressing the Cancel button. |
2984 | + NOTE: Command-line completion is not supported. | |
2960 | 2985 | |
2961 | 2986 | inputlist({textlist}) *inputlist()* |
2962 | 2987 | {textlist} must be a list of strings. This list is displayed, |
@@ -2996,6 +3021,7 @@ | ||
2996 | 3021 | |history| stack. |
2997 | 3022 | The result is a String, which is whatever the user actually |
2998 | 3023 | typed on the command-line in response to the issued prompt. |
3024 | + NOTE: Command-line completion is not supported. | |
2999 | 3025 | |
3000 | 3026 | insert({list}, {item} [, {idx}]) *insert()* |
3001 | 3027 | Insert {item} at the start of List {list}. |
@@ -4450,6 +4476,8 @@ | ||
4450 | 4476 | winline() The result is a Number, which is the screen line of the cursor |
4451 | 4477 | in the window. This is counting screen lines from the top of |
4452 | 4478 | the window. The first line is one. |
4479 | + If the cursor was moved the view on the file will be updated | |
4480 | + first, this may cause a scroll. | |
4453 | 4481 | |
4454 | 4482 | *winnr()* |
4455 | 4483 | winnr([{arg}]) The result is a Number, which is the number of the current |
@@ -1,4 +1,4 @@ | ||
1 | -*insert.txt* For Vim version 7.0aa. Last change: 2005 Sep 15 | |
1 | +*insert.txt* For Vim version 7.0aa. Last change: 2005 Sep 18 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -990,16 +990,17 @@ | ||
990 | 990 | |
991 | 991 | When using after CTRL-X CTRL-O after "<" it is completed with tag name |
992 | 992 | available in current context. Inside of tag completion aids to choose |
993 | -proper attributes, and when possible choose appropriate attribute value. | |
993 | +proper attributes, and when possible choose appropriate attribute value | |
994 | +including class names for CSS styles. | |
994 | 995 | |
995 | 996 | When used after "</" CTRL-X CTRL-O will close the last opened tag. |
996 | 997 | |
997 | -File htmlcompletion.vim provides through autoload mechanism | |
998 | +File htmlcomplete.vim provides through |autoload| mechanism | |
998 | 999 | GetLastOpenTag function which can be used in XML files to get name of |
999 | 1000 | last open tag with: > |
1000 | 1001 | |
1001 | - :echo htmlcompletion#GetLastOpenTag("b:unaryTagsStack") | |
1002 | -< | |
1002 | + :echo htmlcomplete#GetLastOpenTag("b:unaryTagsStack") | |
1003 | + | |
1003 | 1004 | |
1004 | 1005 | ============================================================================== |
1005 | 1006 | 8. Insert mode commands *inserting* |
@@ -4992,6 +4992,7 @@ | ||
4992 | 4992 | ft-groff-syntax syntax.txt /*ft-groff-syntax* |
4993 | 4993 | ft-gsp-syntax syntax.txt /*ft-gsp-syntax* |
4994 | 4994 | ft-haskell-syntax syntax.txt /*ft-haskell-syntax* |
4995 | +ft-html-omni insert.txt /*ft-html-omni* | |
4995 | 4996 | ft-html-syntax syntax.txt /*ft-html-syntax* |
4996 | 4997 | ft-htmlos-syntax syntax.txt /*ft-htmlos-syntax* |
4997 | 4998 | ft-ia64-syntax syntax.txt /*ft-ia64-syntax* |
@@ -5163,6 +5164,7 @@ | ||
5163 | 5164 | getcharmod() eval.txt /*getcharmod()* |
5164 | 5165 | getcmdline() eval.txt /*getcmdline()* |
5165 | 5166 | getcmdpos() eval.txt /*getcmdpos()* |
5167 | +getcmdtype() eval.txt /*getcmdtype()* | |
5166 | 5168 | getcwd() eval.txt /*getcwd()* |
5167 | 5169 | getfontname() eval.txt /*getfontname()* |
5168 | 5170 | getfperm() eval.txt /*getfperm()* |
@@ -5294,6 +5296,7 @@ | ||
5294 | 5296 | hebrew.txt hebrew.txt /*hebrew.txt* |
5295 | 5297 | help various.txt /*help* |
5296 | 5298 | help-context help.txt /*help-context* |
5299 | +help-tags tags 1 | |
5297 | 5300 | help-translated various.txt /*help-translated* |
5298 | 5301 | help-xterm-window various.txt /*help-xterm-window* |
5299 | 5302 | help.txt help.txt /*help.txt* |
@@ -7319,6 +7322,13 @@ | ||
7319 | 7322 | zg spell.txt /*zg* |
7320 | 7323 | zh scroll.txt /*zh* |
7321 | 7324 | zi fold.txt /*zi* |
7325 | +zip zip.txt /*zip* | |
7326 | +zip-contents zip.txt /*zip-contents* | |
7327 | +zip-copyright zip.txt /*zip-copyright* | |
7328 | +zip-history zip.txt /*zip-history* | |
7329 | +zip-manual zip.txt /*zip-manual* | |
7330 | +zip-usage zip.txt /*zip-usage* | |
7331 | +zip.txt zip.txt /*zip.txt* | |
7322 | 7332 | zj fold.txt /*zj* |
7323 | 7333 | zk fold.txt /*zk* |
7324 | 7334 | zl scroll.txt /*zl* |
@@ -1,4 +1,4 @@ | ||
1 | -*todo.txt* For Vim version 7.0aa. Last change: 2005 Sep 16 | |
1 | +*todo.txt* For Vim version 7.0aa. Last change: 2005 Sep 20 | |
2 | 2 | |
3 | 3 | |
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -32,6 +32,20 @@ | ||
32 | 32 | |
33 | 33 | Test11 fails sometimes. (athena, huge features) |
34 | 34 | |
35 | +ml_get errors: :%s/^\_s\+$//gc | |
36 | +And: Insert mode in one window, long file, click in other window, short file. | |
37 | + | |
38 | +'scrolljump' negative used as a percentage, e.g. -50 is 50% of window height? | |
39 | + | |
40 | +Spelling: | |
41 | +- suggestion for "a an" includes "an an", which is marked bad. Check | |
42 | + suggestions for not being a bad word (when split)? | |
43 | +- CTRL-X s doesn't consider 'spellcapcheck'. | |
44 | +- Have spellbadword() return a list with bad word and reason it's bad? | |
45 | + (rare/local/bad/caps) | |
46 | +- spellsuggest() needs a way to require a capital. A flag or context? | |
47 | +- Underscore in REP items stands for space. | |
48 | + | |
35 | 49 | ccomplete: |
36 | 50 | - How to use a popup menu? |
37 | 51 | - When a typedef or struct is local to a file only use it in that file? |
@@ -1726,7 +1740,6 @@ | ||
1726 | 1740 | filecopy(from, to) Copy a file |
1727 | 1741 | shorten(fname) shorten a file name, like home_replace() |
1728 | 1742 | perl(cmd) call Perl and return string |
1729 | - input(prompt, complete) like input() but do specified completion | |
1730 | 1743 | inputrl() like input() but right-to-left |
1731 | 1744 | virtualmode() add argument to obtain whether "$" was used in |
1732 | 1745 | Visual block mode. |
@@ -447,6 +447,8 @@ | ||
447 | 447 | |get()| get an item from a List or Dictionary |
448 | 448 | |getbufline()| get a list of lines from a specified buffer |
449 | 449 | (Yegappan Lakshmanan) |
450 | +|getcmdtype()| return the current command-line type | |
451 | + (Yegappan Lakshmanan) | |
450 | 452 | |getfontname()| get actual font name being used |
451 | 453 | |getfperm()| get file permission string (Nikolai Weibull) |
452 | 454 | |getftype()| get type of file (Nikolai Weibull) |
@@ -812,6 +814,9 @@ | ||
812 | 814 | When 'foldcolumn' is one then put as much info in it as possible. This allows |
813 | 815 | closing a fold with the mouse by clicking on the '-'. |
814 | 816 | |
817 | +input() takes an optional completion argument to specify the type of | |
818 | +completion supported for the input. (Yegappan Lakshmanan) | |
819 | + | |
815 | 820 | ============================================================================== |
816 | 821 | COMPILE TIME CHANGES *compile-changes-7* |
817 | 822 |
@@ -1,7 +1,7 @@ | ||
1 | 1 | " Vim support file to detect file types |
2 | 2 | " |
3 | 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
4 | -" Last Change: 2005 Aug 29 | |
4 | +" Last Change: 2005 Sep 19 | |
5 | 5 | |
6 | 6 | " Listen very carefully, I will say this only once |
7 | 7 | if exists("did_load_filetypes") |
@@ -1882,6 +1882,9 @@ | ||
1882 | 1882 | " Most of these should call s:StarSetf() to avoid names ending in .gz and the |
1883 | 1883 | " like are used. |
1884 | 1884 | |
1885 | +" Asterisk config file | |
1886 | +au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk') | |
1887 | + | |
1885 | 1888 | " BIND zone |
1886 | 1889 | au BufNewFile,BufRead /var/named/* call s:StarSetf('bindzone') |
1887 | 1890 |
@@ -1,7 +1,7 @@ | ||
1 | 1 | " Vim support file to detect file types in scripts |
2 | 2 | " |
3 | 3 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
4 | -" Last change: 2005 May 20 | |
4 | +" Last change: 2005 Sep 20 | |
5 | 5 | |
6 | 6 | " This file is called by an autocommand for every file that has just been |
7 | 7 | " loaded into a buffer. It checks if the type of file can be recognized by |
@@ -182,6 +182,7 @@ | ||
182 | 182 | " - "Index: <filename>" in the first line (CVS file) |
183 | 183 | elseif s:line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|# It was generated by makepatch \|Index:\s\+\f\+$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\)' |
184 | 184 | \ || (s:line1 =~ '^--- ' && s:line2 =~ '^+++ ') |
185 | + \ || (s:line1 =~ '^\* looking for ' && s:line2 =~ '^\* comparing to ') | |
185 | 186 | \ || (s:line1 =~ '^\*\*\* ' && s:line2 =~ '^--- ') |
186 | 187 | set ft=diff |
187 | 188 |
@@ -1,5 +1,5 @@ | ||
1 | 1 | *** en_US.orig.aff Fri Apr 15 13:20:36 2005 |
2 | ---- en_US.aff Sun Jul 31 22:17:40 2005 | |
2 | +--- en_US.aff Tue Sep 20 19:41:00 2005 | |
3 | 3 | *************** |
4 | 4 | *** 3,4 **** |
5 | 5 | --- 3,134 ---- |
@@ -165,12 +165,35 @@ | ||
165 | 165 | ! SFX G 0 ing [^e] |
166 | 166 | |
167 | 167 | *************** |
168 | +*** 99,101 **** | |
169 | + | |
170 | +! REP 88 | |
171 | + REP a ei | |
172 | +--- 229,231 ---- | |
173 | + | |
174 | +! REP 91 | |
175 | + REP a ei | |
176 | +*************** | |
168 | 177 | *** 137,138 **** |
169 | 178 | --- 267,270 ---- |
170 | 179 | REP uy i |
171 | 180 | + REP y ie |
172 | 181 | + REP ie y |
173 | 182 | REP i ee |
183 | +*************** | |
184 | +*** 174,175 **** | |
185 | +--- 306,308 ---- | |
186 | + REP ew ue | |
187 | ++ REP uf ough | |
188 | + REP uff ough | |
189 | +*************** | |
190 | +*** 188 **** | |
191 | +--- 321,325 ---- | |
192 | + REP shun cion | |
193 | ++ REP the_the the | |
194 | ++ REP an_an an | |
195 | ++ REP an_a a | |
196 | ++ REP a_an an | |
174 | 197 | *** en_US.orig.dic Fri Apr 15 13:20:36 2005 |
175 | 198 | --- en_US.dic Tue Aug 16 17:03:31 2005 |
176 | 199 | *************** |
@@ -141,7 +141,7 @@ | ||
141 | 141 | + REP zoz z.o.z. |
142 | 142 | + |
143 | 143 | *** nl_NL.orig.dic Sun Jul 3 18:24:07 2005 |
144 | ---- nl_NL.dic Sat Aug 13 14:10:15 2005 | |
144 | +--- nl_NL.dic Mon Sep 19 20:25:09 2005 | |
145 | 145 | *************** |
146 | 146 | *** 1,3 **** |
147 | 147 | 119937 |
@@ -259,7 +259,7 @@ | ||
259 | 259 | voorjaarsmoeheid |
260 | 260 | *************** |
261 | 261 | *** 119938 **** |
262 | ---- 119963,120139 ---- | |
262 | +--- 119963,120142 ---- | |
263 | 263 | überhaupt |
264 | 264 | + Christiaan/X |
265 | 265 | + Fred/X |
@@ -436,4 +436,7 @@ | ||
436 | 436 | + bijv. |
437 | 437 | + Gerard |
438 | 438 | |
439 | ++ Luc | |
439 | 440 | + Luuk |
441 | ++ Gert | |
442 | ++ Marion |
@@ -0,0 +1,73 @@ | ||
1 | +" Vim syntax file | |
2 | +" Language: Asterisk config file | |
3 | +" Maintainer: brc007 | |
4 | +" Last Change: 2005 Sep 19 | |
5 | +" version 0.2 | |
6 | +" | |
7 | +" Additional changes made 2005 Mar 7 by Corydon76 | |
8 | +" * CVS priority, including n and s, and new label definitions | |
9 | +" * ENV( and LEN( support | |
10 | +" * Class patterns in extensions now match only the class pattern (instead of to a following expression) | |
11 | +" * anthm's functions are matched | |
12 | +" * Variables now appear in their own colors inside expressions | |
13 | + | |
14 | +" For version 5.x: Clear all syntax items | |
15 | +" For version 6.x: Quit when a syntax file was already loaded | |
16 | +if version < 600 | |
17 | + syntax clear | |
18 | +elseif exists("b:current_syntax") | |
19 | + finish | |
20 | +endif | |
21 | + | |
22 | +"testing only | |
23 | +syn sync clear | |
24 | +syn sync fromstart | |
25 | + | |
26 | + | |
27 | +syn keyword asteriskTodo TODO contained | |
28 | +syn match asteriskComment ";.*" contains=asteriskTodo | |
29 | +syn match asteriskContext "\[.\{-}\]" | |
30 | +syn match asteriskExten "^\s*exten\s*=>" | |
31 | +syn match asteriskApp "\s*,\s*\zs[a-zA-Z]*\ze" | |
32 | +" Digits plus oldlabel (newlabel) | |
33 | +syn match asteriskPriority ",[[:digit:]]\+\(+[[:alpha:]][[:alnum:]_]*\)\?\(([[:alpha:]][[:alnum:]_]*)\)\?," | |
34 | +" s or n plus digits (newlabel) | |
35 | +syn match asteriskPriority ",[sn]\(+[[:digit:]]\+\)\?\(([[:alpha:]][[:alnum:]_]*)\)\?," | |
36 | +syn match asteriskIncludeBad "^\s*#\s*[[:alnum:]]*" | |
37 | +syn match asteriskInclude "^\s#\sinclude\s.*" | |
38 | +syn match asteriskVar "\${_\{0,2}[[:alpha:]][[:alnum:]_]*\(:[[:digit:]]\+\)\{0,2}}" | |
39 | +syn match asteriskVarLen "\${_\{0,2}[[:alpha:]][[:alnum:]_]*(.\{-})}" contains=asteriskVar,asteriskVarLen,asteriskExp | |
40 | +syn match asteriskExp "\$\[.\{-}\]" contains=asteriskVar,asteriskVarLen,asteriskExp | |
41 | +syn match asteriskFunc "\$([[:alpha:]][[:alnum:]_]*.*)" contains=asteriskVar,asteriskVarLen,asteriskExp | |
42 | + | |
43 | +" Define the default highlighting. | |
44 | +" For version 5.7 and earlier: only when not done already | |
45 | +" For version 5.8 and later: only when an item doesn't have highlighting yet | |
46 | +:if version >= 508 || !exists("did_conf_syntax_inits") | |
47 | + if version < 508 | |
48 | + let did_conf_syntax_inits = 1 | |
49 | + command -nargs=+ HiLink hi link <args> | |
50 | + else | |
51 | + command -nargs=+ HiLink hi def link <args> | |
52 | + endif | |
53 | + | |
54 | + | |
55 | + HiLink asteriskComment Comment | |
56 | +" not sure what type this should be, using String for testing. | |
57 | + HiLink asteriskExten String | |
58 | +" same here | |
59 | + HiLink asteriskContext Identifier | |
60 | + HiLink asteriskApplication Statement | |
61 | + HiLink asteriskInclude Preproc | |
62 | + HiLink asteriskIncludeBad Error | |
63 | + HiLink asteriskPriority Preproc | |
64 | + HiLink asteriskVar String | |
65 | + HiLink asteriskVarLen Function | |
66 | + HiLink asteriskExp Type | |
67 | + delcommand HiLink | |
68 | +endif | |
69 | + | |
70 | + | |
71 | +let b:current_syntax = "asterisk" | |
72 | + | |
73 | +" vim: ts=8 sw=2 |
@@ -668,18 +668,18 @@ | ||
668 | 668 | for (;;) |
669 | 669 | { |
670 | 670 | ok = FALSE; |
671 | - fd = fopen((char *)tmp_orig, "w"); | |
671 | + fd = mch_fopen((char *)tmp_orig, "w"); | |
672 | 672 | if (fd != NULL) |
673 | 673 | { |
674 | 674 | fwrite("line1\n", (size_t)6, (size_t)1, fd); |
675 | 675 | fclose(fd); |
676 | - fd = fopen((char *)tmp_new, "w"); | |
676 | + fd = mch_fopen((char *)tmp_new, "w"); | |
677 | 677 | if (fd != NULL) |
678 | 678 | { |
679 | 679 | fwrite("line2\n", (size_t)6, (size_t)1, fd); |
680 | 680 | fclose(fd); |
681 | 681 | diff_file(tmp_orig, tmp_new, tmp_diff); |
682 | - fd = fopen((char *)tmp_diff, "r"); | |
682 | + fd = mch_fopen((char *)tmp_diff, "r"); | |
683 | 683 | if (fd != NULL) |
684 | 684 | { |
685 | 685 | char_u linebuf[LBUFLEN]; |
@@ -1144,7 +1144,7 @@ | ||
1144 | 1144 | long count_orig, count_new; |
1145 | 1145 | int notset = TRUE; /* block "*dp" not set yet */ |
1146 | 1146 | |
1147 | - fd = fopen((char *)fname, "r"); | |
1147 | + fd = mch_fopen((char *)fname, "r"); | |
1148 | 1148 | if (fd == NULL) |
1149 | 1149 | { |
1150 | 1150 | EMSG(_("E98: Cannot read diff output")); |
@@ -504,6 +504,7 @@ | ||
504 | 504 | static void f_getcharmod __ARGS((typval_T *argvars, typval_T *rettv)); |
505 | 505 | static void f_getcmdline __ARGS((typval_T *argvars, typval_T *rettv)); |
506 | 506 | static void f_getcmdpos __ARGS((typval_T *argvars, typval_T *rettv)); |
507 | +static void f_getcmdtype __ARGS((typval_T *argvars, typval_T *rettv)); | |
507 | 508 | static void f_getcwd __ARGS((typval_T *argvars, typval_T *rettv)); |
508 | 509 | static void f_getfontname __ARGS((typval_T *argvars, typval_T *rettv)); |
509 | 510 | static void f_getfperm __ARGS((typval_T *argvars, typval_T *rettv)); |
@@ -6769,6 +6770,7 @@ | ||
6769 | 6770 | {"getcharmod", 0, 0, f_getcharmod}, |
6770 | 6771 | {"getcmdline", 0, 0, f_getcmdline}, |
6771 | 6772 | {"getcmdpos", 0, 0, f_getcmdpos}, |
6773 | + {"getcmdtype", 0, 0, f_getcmdtype}, | |
6772 | 6774 | {"getcwd", 0, 0, f_getcwd}, |
6773 | 6775 | {"getfontname", 0, 1, f_getfontname}, |
6774 | 6776 | {"getfperm", 1, 1, f_getfperm}, |
@@ -6799,7 +6801,7 @@ | ||
6799 | 6801 | {"iconv", 3, 3, f_iconv}, |
6800 | 6802 | {"indent", 1, 1, f_indent}, |
6801 | 6803 | {"index", 2, 4, f_index}, |
6802 | - {"input", 1, 2, f_input}, | |
6804 | + {"input", 1, 3, f_input}, | |
6803 | 6805 | {"inputdialog", 1, 3, f_inputdialog}, |
6804 | 6806 | {"inputlist", 1, 1, f_inputlist}, |
6805 | 6807 | {"inputrestore", 0, 0, f_inputrestore}, |
@@ -9438,6 +9440,24 @@ | ||
9438 | 9440 | } |
9439 | 9441 | |
9440 | 9442 | /* |
9443 | + * "getcmdtype()" function | |
9444 | + */ | |
9445 | +/*ARGSUSED*/ | |
9446 | + static void | |
9447 | +f_getcmdtype(argvars, rettv) | |
9448 | + typval_T *argvars; | |
9449 | + typval_T *rettv; | |
9450 | +{ | |
9451 | + rettv->v_type = VAR_STRING; | |
9452 | + rettv->vval.v_string = alloc(2); | |
9453 | + if (rettv->vval.v_string != NULL) | |
9454 | + { | |
9455 | + rettv->vval.v_string[0] = get_cmdline_type(); | |
9456 | + rettv->vval.v_string[1] = NUL; | |
9457 | + } | |
9458 | +} | |
9459 | + | |
9460 | +/* | |
9441 | 9461 | * "getcwd()" function |
9442 | 9462 | */ |
9443 | 9463 | /*ARGSUSED*/ |
@@ -10794,6 +10814,8 @@ | ||
10794 | 10814 | char_u buf[NUMBUFLEN]; |
10795 | 10815 | int cmd_silent_save = cmd_silent; |
10796 | 10816 | char_u *defstr = (char_u *)""; |
10817 | + int xp_type = EXPAND_NOTHING; | |
10818 | + char_u *xp_arg = NULL; | |
10797 | 10819 | |
10798 | 10820 | rettv->v_type = VAR_STRING; |
10799 | 10821 |
@@ -10835,9 +10857,31 @@ | ||
10835 | 10857 | stuffReadbuffSpec(defstr); |
10836 | 10858 | } |
10837 | 10859 | |
10860 | + if (argvars[2].v_type != VAR_UNKNOWN) | |
10861 | + { | |
10862 | + char_u *xp_name; | |
10863 | + int xp_namelen; | |
10864 | + long argt; | |
10865 | + | |
10866 | + rettv->vval.v_string = NULL; | |
10867 | + | |
10868 | + xp_name = get_tv_string_buf_chk(&argvars[2], buf); | |
10869 | + if (xp_name == NULL) | |
10870 | + return; | |
10871 | + | |
10872 | + xp_namelen = STRLEN(xp_name); | |
10873 | + | |
10874 | + if (parse_compl_arg(xp_name, xp_namelen, &xp_type, &argt, &xp_arg) | |
10875 | + == FAIL) | |
10876 | + return; | |
10877 | + } | |
10878 | + | |
10838 | 10879 | if (defstr != NULL) |
10839 | 10880 | rettv->vval.v_string = |
10840 | - getcmdline_prompt(inputsecret_flag ? NUL : '@', p, echo_attr); | |
10881 | + getcmdline_prompt(inputsecret_flag ? NUL : '@', p, echo_attr, | |
10882 | + xp_type, xp_arg); | |
10883 | + | |
10884 | + vim_free(xp_arg); | |
10841 | 10885 | |
10842 | 10886 | /* since the user typed this, no need to wait for return */ |
10843 | 10887 | need_wait_return = FALSE; |
@@ -17680,10 +17724,8 @@ | ||
17680 | 17724 | } |
17681 | 17725 | msg_putchar(')'); |
17682 | 17726 | msg_clr_eos(); |
17683 | -#ifdef FEAT_EVAL | |
17684 | 17727 | if (p_verbose > 0) |
17685 | 17728 | last_set_msg(fp->uf_script_ID); |
17686 | -#endif | |
17687 | 17729 | } |
17688 | 17730 | |
17689 | 17731 | /* |
@@ -5688,7 +5688,7 @@ | ||
5688 | 5688 | { |
5689 | 5689 | for (fi = 0; fi < fcount; ++fi) |
5690 | 5690 | { |
5691 | - fd = fopen((char *)fnames[fi], "r"); | |
5691 | + fd = mch_fopen((char *)fnames[fi], "r"); | |
5692 | 5692 | if (fd != NULL) |
5693 | 5693 | { |
5694 | 5694 | vim_fgets(IObuff, IOSIZE, fd); |
@@ -5953,7 +5953,7 @@ | ||
5953 | 5953 | STRCPY(NameBuff, dir); |
5954 | 5954 | add_pathsep(NameBuff); |
5955 | 5955 | STRCAT(NameBuff, tagfname); |
5956 | - fd_tags = fopen((char *)NameBuff, "w"); | |
5956 | + fd_tags = mch_fopen((char *)NameBuff, "w"); | |
5957 | 5957 | if (fd_tags == NULL) |
5958 | 5958 | { |
5959 | 5959 | EMSG2(_("E152: Cannot open %s for writing"), NameBuff); |
@@ -5988,7 +5988,7 @@ | ||
5988 | 5988 | */ |
5989 | 5989 | for (fi = 0; fi < filecount && !got_int; ++fi) |
5990 | 5990 | { |
5991 | - fd = fopen((char *)files[fi], "r"); | |
5991 | + fd = mch_fopen((char *)files[fi], "r"); | |
5992 | 5992 | if (fd == NULL) |
5993 | 5993 | { |
5994 | 5994 | EMSG2(_("E153: Unable to open %s for reading"), files[fi]); |
@@ -167,7 +167,7 @@ | ||
167 | 167 | if (!debug_greedy) |
168 | 168 | save_typeahead(&typeaheadbuf); |
169 | 169 | |
170 | - cmdline = getcmdline_prompt('>', NULL, 0); | |
170 | + cmdline = getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL); | |
171 | 171 | |
172 | 172 | if (!debug_greedy) |
173 | 173 | restore_typeahead(&typeaheadbuf); |
@@ -1031,7 +1031,7 @@ | ||
1031 | 1031 | |
1032 | 1032 | if (profile_fname != NULL) |
1033 | 1033 | { |
1034 | - fd = fopen((char *)profile_fname, "w"); | |
1034 | + fd = mch_fopen((char *)profile_fname, "w"); | |
1035 | 1035 | if (fd == NULL) |
1036 | 1036 | EMSG2(_(e_notopen), profile_fname); |
1037 | 1037 | else |
@@ -1149,7 +1149,7 @@ | ||
1149 | 1149 | fprintf(fd, "\n"); |
1150 | 1150 | fprintf(fd, "count total (s) self (s)\n"); |
1151 | 1151 | |
1152 | - sfd = fopen((char *)si->sn_name, "r"); | |
1152 | + sfd = mch_fopen((char *)si->sn_name, "r"); | |
1153 | 1153 | if (sfd == NULL) |
1154 | 1154 | fprintf(fd, "Cannot open file!\n"); |
1155 | 1155 | else |
@@ -5267,66 +5267,15 @@ | ||
5267 | 5267 | } |
5268 | 5268 | else if (STRNICMP(attr, "complete", attrlen) == 0) |
5269 | 5269 | { |
5270 | - char_u *arg = NULL; | |
5271 | - size_t arglen = 0; | |
5272 | - | |
5273 | 5270 | if (val == NULL) |
5274 | 5271 | { |
5275 | - EMSG(_("E179: argument required for complete")); | |
5272 | + EMSG(_("E179: argument required for -complete")); | |
5276 | 5273 | return FAIL; |
5277 | 5274 | } |
5278 | - /* Look for any argument part - which is the part after any ',' */ | |
5279 | - for (i = 0; i < (int)vallen; ++i) | |
5280 | - { | |
5281 | - if (val[i] == ',') | |
5282 | - { | |
5283 | - arg = &val[i + 1]; | |
5284 | - arglen = vallen - i - 1; | |
5285 | - vallen = i; | |
5286 | - break; | |
5287 | - } | |
5288 | - } | |
5289 | - | |
5290 | - for (i = 0; command_complete[i].expand != 0; ++i) | |
5291 | - { | |
5292 | - if (STRLEN(command_complete[i].name) == vallen | |
5293 | - && STRNCMP(val, command_complete[i].name, vallen) == 0) | |
5294 | - { | |
5295 | - *compl = command_complete[i].expand; | |
5296 | - if (command_complete[i].expand == EXPAND_BUFFERS) | |
5297 | - *argt |= BUFNAME; | |
5298 | - else if (command_complete[i].expand == EXPAND_DIRECTORIES | |
5299 | - || command_complete[i].expand == EXPAND_FILES) | |
5300 | - *argt |= XFILE; | |
5301 | - break; | |
5302 | - } | |
5303 | - } | |
5304 | - | |
5305 | - if (command_complete[i].expand == 0) | |
5306 | - { | |
5307 | - EMSG2(_("E180: Invalid complete value: %s"), val); | |
5275 | + | |
5276 | + if (parse_compl_arg(val, (int)vallen, compl, argt, compl_arg) | |
5277 | + == FAIL) | |
5308 | 5278 | return FAIL; |
5309 | - } | |
5310 | -#if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) | |
5311 | - if (*compl != EXPAND_USER_DEFINED && *compl != EXPAND_USER_LIST && | |
5312 | - arg != NULL) | |
5313 | -#else | |
5314 | - if (arg != NULL) | |
5315 | -#endif | |
5316 | - { | |
5317 | - EMSG(_("E468: Completion argument only allowed for custom completion")); | |
5318 | - return FAIL; | |
5319 | - } | |
5320 | -#if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) | |
5321 | - if ((*compl == EXPAND_USER_DEFINED || *compl == EXPAND_USER_LIST) && | |
5322 | - arg == NULL) | |
5323 | - { | |
5324 | - EMSG(_("E467: Custom completion requires a function argument")); | |
5325 | - return FAIL; | |
5326 | - } | |
5327 | - if (arg != NULL) | |
5328 | - *compl_arg = vim_strnsave(arg, (int)arglen); | |
5329 | -#endif | |
5330 | 5279 | } |
5331 | 5280 | else |
5332 | 5281 | { |
@@ -5914,6 +5863,86 @@ | ||
5914 | 5863 | |
5915 | 5864 | #endif /* FEAT_USR_CMDS */ |
5916 | 5865 | |
5866 | +#if defined(FEAT_USR_CMDS) || defined(FEAT_EVAL) || defined(PROTO) | |
5867 | +/* | |
5868 | + * Parse a completion argument "value[vallen]". | |
5869 | + * The detected completion goes in "*complp", argument type in "*argt". | |
5870 | + * When there is an argument, for function and user defined completion, it's | |
5871 | + * copied to allocated memory and stored in "*compl_arg". | |
5872 | + * Returns FAIL if something is wrong. | |
5873 | + */ | |
5874 | + int | |
5875 | +parse_compl_arg(value, vallen, complp, argt, compl_arg) | |
5876 | + char_u *value; | |
5877 | + int vallen; | |
5878 | + int *complp; | |
5879 | + long *argt; | |
5880 | + char_u **compl_arg; | |
5881 | +{ | |
5882 | + char_u *arg = NULL; | |
5883 | + size_t arglen = 0; | |
5884 | + int i; | |
5885 | + int valend = vallen; | |
5886 | + | |
5887 | + /* Look for any argument part - which is the part after any ',' */ | |
5888 | + for (i = 0; i < vallen; ++i) | |
5889 | + { | |
5890 | + if (value[i] == ',') | |
5891 | + { | |
5892 | + arg = &value[i + 1]; | |
5893 | + arglen = vallen - i - 1; | |
5894 | + valend = i; | |
5895 | + break; | |
5896 | + } | |
5897 | + } | |
5898 | + | |
5899 | + for (i = 0; command_complete[i].expand != 0; ++i) | |
5900 | + { | |
5901 | + if (STRLEN(command_complete[i].name) == valend | |
5902 | + && STRNCMP(value, command_complete[i].name, valend) == 0) | |
5903 | + { | |
5904 | + *complp = command_complete[i].expand; | |
5905 | + if (command_complete[i].expand == EXPAND_BUFFERS) | |
5906 | + *argt |= BUFNAME; | |
5907 | + else if (command_complete[i].expand == EXPAND_DIRECTORIES | |
5908 | + || command_complete[i].expand == EXPAND_FILES) | |
5909 | + *argt |= XFILE; | |
5910 | + break; | |
5911 | + } | |
5912 | + } | |
5913 | + | |
5914 | + if (command_complete[i].expand == 0) | |
5915 | + { | |
5916 | + EMSG2(_("E180: Invalid complete value: %s"), value); | |
5917 | + return FAIL; | |
5918 | + } | |
5919 | + | |
5920 | +# if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) | |
5921 | + if (*complp != EXPAND_USER_DEFINED && *complp != EXPAND_USER_LIST | |
5922 | + && arg != NULL) | |
5923 | +# else | |
5924 | + if (arg != NULL) | |
5925 | +# endif | |
5926 | + { | |
5927 | + EMSG(_("E468: Completion argument only allowed for custom completion")); | |
5928 | + return FAIL; | |
5929 | + } | |
5930 | + | |
5931 | +# if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) | |
5932 | + if ((*complp == EXPAND_USER_DEFINED || *complp == EXPAND_USER_LIST) | |
5933 | + && arg == NULL) | |
5934 | + { | |
5935 | + EMSG(_("E467: Custom completion requires a function argument")); | |
5936 | + return FAIL; | |
5937 | + } | |
5938 | + | |
5939 | + if (arg != NULL) | |
5940 | + *compl_arg = vim_strnsave(arg, (int)arglen); | |
5941 | +# endif | |
5942 | + return OK; | |
5943 | +} | |
5944 | +#endif | |
5945 | + | |
5917 | 5946 | static void |
5918 | 5947 | ex_colorscheme(eap) |
5919 | 5948 | exarg_T *eap; |
@@ -31,6 +31,11 @@ | ||
31 | 31 | int cmdattr; /* attributes for prompt */ |
32 | 32 | int overstrike; /* Typing mode on the command line. Shared by |
33 | 33 | getcmdline() and put_on_cmdline(). */ |
34 | + int xp_context; /* type of expansion */ | |
35 | +# ifdef FEAT_EVAL | |
36 | + char_u *xp_arg; /* user-defined expansion arg */ | |
37 | + int input_fn; /* Invoked for input() function */ | |
38 | +# endif | |
34 | 39 | }; |
35 | 40 | |
36 | 41 | static struct cmdline_info ccline; /* current cmdline_info */ |
@@ -254,6 +259,15 @@ | ||
254 | 259 | xpc.xp_context = EXPAND_NOTHING; |
255 | 260 | xpc.xp_backslash = XP_BS_NONE; |
256 | 261 | |
262 | +#if defined(FEAT_EVAL) | |
263 | + if (ccline.input_fn) | |
264 | + { | |
265 | + xpc.xp_context = ccline.xp_context; | |
266 | + xpc.xp_pattern = ccline.cmdbuff; | |
267 | + xpc.xp_arg = ccline.xp_arg; | |
268 | + } | |
269 | +#endif | |
270 | + | |
257 | 271 | /* |
258 | 272 | * Avoid scrolling when called by a recursive do_cmdline(), e.g. when |
259 | 273 | * doing ":@0" when register 0 doesn't contain a CR. |
@@ -414,6 +428,13 @@ | ||
414 | 428 | if (p_wmnu && wild_menu_showing != 0) |
415 | 429 | { |
416 | 430 | int skt = KeyTyped; |
431 | + int old_RedrawingDisabled; | |
432 | + | |
433 | + if (ccline.input_fn) | |
434 | + { | |
435 | + old_RedrawingDisabled = RedrawingDisabled; | |
436 | + RedrawingDisabled = 0; | |
437 | + } | |
417 | 438 | |
418 | 439 | if (wild_menu_showing == WM_SCROLLED) |
419 | 440 | { |
@@ -442,6 +463,8 @@ | ||
442 | 463 | # endif |
443 | 464 | redraw_statuslines(); |
444 | 465 | } |
466 | + if (ccline.input_fn) | |
467 | + RedrawingDisabled = old_RedrawingDisabled; | |
445 | 468 | KeyTyped = skt; |
446 | 469 | wild_menu_showing = 0; |
447 | 470 | } |
@@ -1791,10 +1814,12 @@ | ||
1791 | 1814 | * Returns the command line in allocated memory, or NULL. |
1792 | 1815 | */ |
1793 | 1816 | char_u * |
1794 | -getcmdline_prompt(firstc, prompt, attr) | |
1817 | +getcmdline_prompt(firstc, prompt, attr, xp_context, xp_arg) | |
1795 | 1818 | int firstc; |
1796 | 1819 | char_u *prompt; /* command line prompt */ |
1797 | 1820 | int attr; /* attributes for prompt */ |
1821 | + int xp_context; /* type of expansion */ | |
1822 | + char_u *xp_arg; /* user-defined expansion argument */ | |
1798 | 1823 | { |
1799 | 1824 | char_u *s; |
1800 | 1825 | struct cmdline_info save_ccline; |
@@ -1803,6 +1828,11 @@ | ||
1803 | 1828 | save_cmdline(&save_ccline); |
1804 | 1829 | ccline.cmdprompt = prompt; |
1805 | 1830 | ccline.cmdattr = attr; |
1831 | +# ifdef FEAT_EVAL | |
1832 | + ccline.xp_context = xp_context; | |
1833 | + ccline.xp_arg = xp_arg; | |
1834 | + ccline.input_fn = (firstc == '@'); | |
1835 | +# endif | |
1806 | 1836 | s = getcmdline(firstc, 1L, 0); |
1807 | 1837 | restore_cmdline(&save_ccline); |
1808 | 1838 | /* Restore msg_col, the prompt from input() may have changed it. */ |
@@ -1830,7 +1860,7 @@ | ||
1830 | 1860 | static void |
1831 | 1861 | set_cmdspos() |
1832 | 1862 | { |
1833 | - if (ccline.cmdfirstc) | |
1863 | + if (ccline.cmdfirstc != NUL) | |
1834 | 1864 | ccline.cmdspos = 1 + ccline.cmdindent; |
1835 | 1865 | else |
1836 | 1866 | ccline.cmdspos = 0 + ccline.cmdindent; |
@@ -2222,7 +2252,7 @@ | ||
2222 | 2252 | |
2223 | 2253 | old_row = msg_row; |
2224 | 2254 | old_col = msg_col; |
2225 | - cmdspos = ((ccline.cmdfirstc) ? 1 : 0) + ccline.cmdindent; | |
2255 | + cmdspos = ((ccline.cmdfirstc != NUL) ? 1 : 0) + ccline.cmdindent; | |
2226 | 2256 | |
2227 | 2257 | # ifdef FEAT_MBYTE |
2228 | 2258 | if (has_mbyte) |
@@ -2813,14 +2843,14 @@ | ||
2813 | 2843 | |
2814 | 2844 | if (cmd_silent) |
2815 | 2845 | return; |
2816 | - if (ccline.cmdfirstc) | |
2846 | + if (ccline.cmdfirstc != NUL) | |
2817 | 2847 | msg_putchar(ccline.cmdfirstc); |
2818 | 2848 | if (ccline.cmdprompt != NULL) |
2819 | 2849 | { |
2820 | 2850 | msg_puts_attr(ccline.cmdprompt, ccline.cmdattr); |
2821 | 2851 | ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; |
2822 | 2852 | /* do the reverse of set_cmdspos() */ |
2823 | - if (ccline.cmdfirstc) | |
2853 | + if (ccline.cmdfirstc != NUL) | |
2824 | 2854 | --ccline.cmdindent; |
2825 | 2855 | } |
2826 | 2856 | else |
@@ -3843,6 +3873,7 @@ | ||
3843 | 3873 | if (ccline.cmdfirstc != ':' |
3844 | 3874 | #ifdef FEAT_EVAL |
3845 | 3875 | && ccline.cmdfirstc != '>' && ccline.cmdfirstc != '=' |
3876 | + && !ccline.input_fn | |
3846 | 3877 | #endif |
3847 | 3878 | ) |
3848 | 3879 | { |
@@ -3875,6 +3906,12 @@ | ||
3875 | 3906 | if (ccline.cmdfirstc == '=') |
3876 | 3907 | /* pass CMD_SIZE because there is no real command */ |
3877 | 3908 | set_context_for_expression(xp, str, CMD_SIZE); |
3909 | + else if (ccline.input_fn) | |
3910 | + { | |
3911 | + xp->xp_context = ccline.xp_context; | |
3912 | + xp->xp_pattern = ccline.cmdbuff; | |
3913 | + xp->xp_arg = ccline.xp_arg; | |
3914 | + } | |
3878 | 3915 | else |
3879 | 3916 | #endif |
3880 | 3917 | while (nextcomm != NULL) |
@@ -4838,6 +4875,22 @@ | ||
4838 | 4875 | } |
4839 | 4876 | |
4840 | 4877 | /* |
4878 | + * Get the current command-line type. | |
4879 | + * Returns ':' or '/' or '?' or '@' or '>' | |
4880 | + * Only works when the command line is being edited. | |
4881 | + * Returns NUL when something is wrong. | |
4882 | + */ | |
4883 | + int | |
4884 | +get_cmdline_type() | |
4885 | +{ | |
4886 | + struct cmdline_info *p = get_ccline_ptr(); | |
4887 | + | |
4888 | + if (p == NULL) | |
4889 | + return NUL; | |
4890 | + return p->cmdfirstc; | |
4891 | +} | |
4892 | + | |
4893 | +/* | |
4841 | 4894 | * Calculate history index from a number: |
4842 | 4895 | * num > 0: seen as identifying number of a history entry |
4843 | 4896 | * num < 0: relative position in history wrt newest entry |
@@ -3483,12 +3483,11 @@ | ||
3483 | 3483 | } |
3484 | 3484 | if (backup != NULL) |
3485 | 3485 | { |
3486 | - | |
3487 | 3486 | /* |
3488 | - * Delete any existing backup and move the current version to | |
3489 | - * the backup. For safety, we don't remove the backup until | |
3490 | - * the write has finished successfully. And if the 'backup' | |
3491 | - * option is set, leave it around. | |
3487 | + * Delete any existing backup and move the current version | |
3488 | + * to the backup. For safety, we don't remove the backup | |
3489 | + * until the write has finished successfully. And if the | |
3490 | + * 'backup' option is set, leave it around. | |
3492 | 3491 | */ |
3493 | 3492 | /* |
3494 | 3493 | * If the renaming of the original file to the backup file |
@@ -1098,7 +1098,7 @@ | ||
1098 | 1098 | FILE *f; |
1099 | 1099 | char_u *tmp = vim_tempname('c'); |
1100 | 1100 | |
1101 | - f = fopen((char *)tmp, "w"); | |
1101 | + f = mch_fopen((char *)tmp, "w"); | |
1102 | 1102 | cs_file_results(f, nummatches); |
1103 | 1103 | fclose(f); |
1104 | 1104 | /* '-' starts a new error list */ |
@@ -201,7 +201,7 @@ | ||
201 | 201 | #endif |
202 | 202 | |
203 | 203 | #ifdef STARTUPTIME |
204 | - time_fd = fopen(STARTUPTIME, "a"); | |
204 | + time_fd = mch_fopen(STARTUPTIME, "a"); | |
205 | 205 | TIME_MSG("--- VIM STARTING ---"); |
206 | 206 | #endif |
207 | 207 |
@@ -161,7 +161,7 @@ | ||
161 | 161 | return; |
162 | 162 | if (fd == NULL) |
163 | 163 | { |
164 | - fd = fopen("xim.log", "w"); | |
164 | + fd = mch_fopen("xim.log", "w"); | |
165 | 165 | if (fd == NULL) |
166 | 166 | { |
167 | 167 | EMSG("Cannot open xim.log"); |
@@ -3034,7 +3034,7 @@ | ||
3034 | 3034 | /* Only give the error message once. */ |
3035 | 3035 | verbose_did_open = TRUE; |
3036 | 3036 | |
3037 | - verbose_fd = fopen((char *)p_vfile, "a"); | |
3037 | + verbose_fd = mch_fopen((char *)p_vfile, "a"); | |
3038 | 3038 | if (verbose_fd == NULL) |
3039 | 3039 | { |
3040 | 3040 | EMSG2(_(e_notopen), p_vfile); |
@@ -3512,7 +3512,8 @@ | ||
3512 | 3512 | cmdline_row = msg_row; |
3513 | 3513 | p1 = getcmdline_prompt(NUL, round == 0 |
3514 | 3514 | ? (char_u *)_("Enter encryption key: ") |
3515 | - : (char_u *)_("Enter same key again: "), 0); | |
3515 | + : (char_u *)_("Enter same key again: "), 0, EXPAND_NOTHING, | |
3516 | + NULL); | |
3516 | 3517 | cmdline_star = FALSE; |
3517 | 3518 | |
3518 | 3519 | if (p1 == NULL) |
@@ -21,6 +21,7 @@ | ||
21 | 21 | char_u *get_user_cmd_flags __ARGS((expand_T *xp, int idx)); |
22 | 22 | char_u *get_user_cmd_nargs __ARGS((expand_T *xp, int idx)); |
23 | 23 | char_u *get_user_cmd_complete __ARGS((expand_T *xp, int idx)); |
24 | +int parse_compl_arg __ARGS((char_u *value, int vallen, int *complp, long *argt, char_u **compl_arg)); | |
24 | 25 | void not_exiting __ARGS((void)); |
25 | 26 | void handle_drop __ARGS((int filec, char_u **filev, int split)); |
26 | 27 | void alist_clear __ARGS((alist_T *al)); |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* ex_getln.c */ |
2 | 2 | char_u *getcmdline __ARGS((int firstc, long count, int indent)); |
3 | -char_u *getcmdline_prompt __ARGS((int firstc, char_u *prompt, int attr)); | |
3 | +char_u *getcmdline_prompt __ARGS((int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg)); | |
4 | 4 | char_u *getexline __ARGS((int c, void *dummy, int indent)); |
5 | 5 | char_u *getexmodeline __ARGS((int promptc, void *dummy, int indent)); |
6 | 6 | int cmdline_overstrike __ARGS((void)); |
@@ -33,6 +33,7 @@ | ||
33 | 33 | char_u *get_cmdline_str __ARGS((void)); |
34 | 34 | int get_cmdline_pos __ARGS((void)); |
35 | 35 | int set_cmdline_pos __ARGS((int pos)); |
36 | +int get_cmdline_type __ARGS((void)); | |
36 | 37 | char_u *get_history_entry __ARGS((int histype, int idx)); |
37 | 38 | int clr_history __ARGS((int histype)); |
38 | 39 | int del_history_entry __ARGS((int histype, char_u *str)); |
@@ -3056,7 +3056,7 @@ | ||
3056 | 3056 | + STRLEN(fnames[fi]) - 3, 3) == 0)) |
3057 | 3057 | continue; |
3058 | 3058 | #endif |
3059 | - fd = fopen((char *)fnames[fi], "r"); | |
3059 | + fd = mch_fopen((char *)fnames[fi], "r"); | |
3060 | 3060 | if (fd != NULL) |
3061 | 3061 | { |
3062 | 3062 | lnum = 1; |
@@ -36,5 +36,5 @@ | ||
36 | 36 | #define VIM_VERSION_NODOT "vim70aa" |
37 | 37 | #define VIM_VERSION_SHORT "7.0aa" |
38 | 38 | #define VIM_VERSION_MEDIUM "7.0aa ALPHA" |
39 | -#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Sep 16)" | |
40 | -#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Sep 16, compiled " | |
39 | +#define VIM_VERSION_LONG "VIM - Vi IMproved 7.0aa ALPHA (2005 Sep 20)" | |
40 | +#define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 7.0aa ALPHA (2005 Sep 20, compiled " |