Mercurial > vim
annotate runtime/scripts.vim @ 6043:a97e5b9dbc26 v7.4.361
updated for version 7.4.361
Problem: Lots of flickering when filling the preview window for 'omnifunc'.
Solution: Disable redrawing. (Hirohito Higashi)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 09 Jul 2014 19:58:24 +0200 |
parents | 2b11ac90d9e9 |
children | 6921742f396a |
rev | line source |
---|---|
7 | 1 " Vim support file to detect file types in scripts |
2 " | |
3 " Maintainer: Bram Moolenaar <Bram@vim.org> | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
3830
diff
changeset
|
4 " Last change: 2013 May 24 |
7 | 5 |
6 " This file is called by an autocommand for every file that has just been | |
7 " loaded into a buffer. It checks if the type of file can be recognized by | |
8 " the file contents. The autocommand is in $VIMRUNTIME/filetype.vim. | |
9 | |
10 | |
11 " Only do the rest when the FileType autocommand has not been triggered yet. | |
12 if did_filetype() | |
13 finish | |
14 endif | |
15 | |
16 " Load the user defined scripts file first | |
17 " Only do this when the FileType autocommand has not been triggered yet | |
279 | 18 if exists("myscriptsfile") && filereadable(expand(myscriptsfile)) |
7 | 19 execute "source " . myscriptsfile |
20 if did_filetype() | |
21 finish | |
22 endif | |
23 endif | |
24 | |
25 " Line continuation is used here, remove 'C' from 'cpoptions' | |
26 let s:cpo_save = &cpo | |
27 set cpo&vim | |
28 | |
29 let s:line1 = getline(1) | |
30 | |
31 if s:line1 =~ "^#!" | |
32 " A script that starts with "#!". | |
33 | |
34 " Check for a line like "#!/usr/bin/env VAR=val bash". Turn it into | |
35 " "#!/usr/bin/bash" to make matching easier. | |
36 if s:line1 =~ '^#!\s*\S*\<env\s' | |
37 let s:line1 = substitute(s:line1, '\S\+=\S\+', '', 'g') | |
38 let s:line1 = substitute(s:line1, '\<env\s\+', '', '') | |
39 endif | |
40 | |
41 " Get the program name. | |
42 " Only accept spaces in PC style paths: "#!c:/program files/perl [args]". | |
279 | 43 " If the word env is used, use the first word after the space: |
44 " "#!/usr/bin/env perl [path/args]" | |
7 | 45 " If there is no path use the first word: "#!perl [path/args]". |
46 " Otherwise get the last word after a slash: "#!/usr/bin/perl [path/args]". | |
47 if s:line1 =~ '^#!\s*\a:[/\\]' | |
48 let s:name = substitute(s:line1, '^#!.*[/\\]\(\i\+\).*', '\1', '') | |
279 | 49 elseif s:line1 =~ '^#!.*\<env\>' |
50 let s:name = substitute(s:line1, '^#!.*\<env\>\s\+\(\i\+\).*', '\1', '') | |
7 | 51 elseif s:line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)' |
52 let s:name = substitute(s:line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '') | |
53 else | |
54 let s:name = substitute(s:line1, '^#!\s*\S*[/\\]\(\i\+\).*', '\1', '') | |
55 endif | |
56 | |
923 | 57 " tcl scripts may have #!/bin/sh in the first line and "exec wish" in the |
58 " third line. Suggested by Steven Atkinson. | |
59 if getline(3) =~ '^exec wish' | |
60 let s:name = 'wish' | |
61 endif | |
62 | |
22 | 63 " Bourne-like shell scripts: bash bash2 ksh ksh93 sh |
64 if s:name =~ '^\(bash\d*\|\|ksh\d*\|sh\)\>' | |
7 | 65 call SetFileTypeSH(s:line1) " defined in filetype.vim |
66 | |
67 " csh scripts | |
68 elseif s:name =~ '^csh\>' | |
69 if exists("g:filetype_csh") | |
26 | 70 call SetFileTypeShell(g:filetype_csh) |
7 | 71 else |
26 | 72 call SetFileTypeShell("csh") |
7 | 73 endif |
74 | |
75 " tcsh scripts | |
76 elseif s:name =~ '^tcsh\>' | |
26 | 77 call SetFileTypeShell("tcsh") |
7 | 78 |
79 " Z shell scripts | |
80 elseif s:name =~ '^zsh\>' | |
81 set ft=zsh | |
82 | |
83 " TCL scripts | |
84 elseif s:name =~ '^\(tclsh\|wish\|expectk\|itclsh\|itkwish\)\>' | |
85 set ft=tcl | |
86 | |
87 " Expect scripts | |
88 elseif s:name =~ '^expect\>' | |
89 set ft=expect | |
90 | |
91 " Gnuplot scripts | |
92 elseif s:name =~ '^gnuplot\>' | |
93 set ft=gnuplot | |
94 | |
95 " Makefiles | |
96 elseif s:name =~ 'make\>' | |
97 set ft=make | |
98 | |
279 | 99 " Lua |
100 elseif s:name =~ 'lua' | |
101 set ft=lua | |
102 | |
2437 | 103 " Perl 6 |
104 elseif s:name =~ 'perl6' | |
105 set ft=perl6 | |
106 | |
7 | 107 " Perl |
108 elseif s:name =~ 'perl' | |
109 set ft=perl | |
110 | |
111 " PHP | |
112 elseif s:name =~ 'php' | |
113 set ft=php | |
114 | |
115 " Python | |
116 elseif s:name =~ 'python' | |
117 set ft=python | |
118 | |
119 " Groovy | |
120 elseif s:name =~ '^groovy\>' | |
121 set ft=groovy | |
122 | |
123 " Ruby | |
124 elseif s:name =~ 'ruby' | |
125 set ft=ruby | |
126 | |
127 " BC calculator | |
128 elseif s:name =~ '^bc\>' | |
129 set ft=bc | |
130 | |
131 " sed | |
132 elseif s:name =~ 'sed\>' | |
133 set ft=sed | |
134 | |
135 " OCaml-scripts | |
136 elseif s:name =~ 'ocaml' | |
137 set ft=ocaml | |
138 | |
139 " Awk scripts | |
140 elseif s:name =~ 'awk\>' | |
141 set ft=awk | |
142 | |
143 " Website MetaLanguage | |
144 elseif s:name =~ 'wml' | |
145 set ft=wml | |
146 | |
147 " Scheme scripts | |
148 elseif s:name =~ 'scheme' | |
149 set ft=scheme | |
150 | |
556 | 151 " CFEngine scripts |
152 elseif s:name =~ 'cfengine' | |
153 set ft=cfengine | |
154 | |
4780 | 155 " Erlang scripts |
156 elseif s:name =~ 'escript' | |
157 set ft=erlang | |
158 | |
7 | 159 endif |
160 unlet s:name | |
161 | |
162 else | |
163 " File does not start with "#!". | |
164 | |
165 let s:line2 = getline(2) | |
166 let s:line3 = getline(3) | |
167 let s:line4 = getline(4) | |
168 let s:line5 = getline(5) | |
169 | |
170 " Bourne-like shell scripts: sh ksh bash bash2 | |
171 if s:line1 =~ '^:$' | |
172 call SetFileTypeSH(s:line1) " defined in filetype.vim | |
173 | |
174 " Z shell scripts | |
2596 | 175 elseif s:line1 =~ '^#compdef\>' || s:line1 =~ '^#autoload\>' || |
176 \ "\n".s:line1."\n".s:line2."\n".s:line3."\n".s:line4."\n".s:line5 =~ '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>' | |
7 | 177 set ft=zsh |
178 | |
179 " ELM Mail files | |
1668 | 180 elseif s:line1 =~ '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$' |
7 | 181 set ft=mail |
182 | |
183 " Mason | |
184 elseif s:line1 =~ '^<[%&].*>' | |
185 set ft=mason | |
186 | |
187 " Vim scripts (must have '" vim' as the first line to trigger this) | |
188 elseif s:line1 =~ '^" *[vV]im$' | |
189 set ft=vim | |
190 | |
191 " MOO | |
192 elseif s:line1 =~ '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$' | |
193 set ft=moo | |
194 | |
195 " Diff file: | |
196 " - "diff" in first line (context diff) | |
197 " - "Only in " in first line | |
198 " - "--- " in first line and "+++ " in second line (unified diff). | |
199 " - "*** " in first line and "--- " in second line (context diff). | |
200 " - "# It was generated by makepatch " in the second line (makepatch diff). | |
201 " - "Index: <filename>" in the first line (CVS file) | |
809 | 202 " - "=== ", line of "=", "---", "+++ " (SVK diff) |
816 | 203 " - "=== ", "--- ", "+++ " (bzr diff, common case) |
204 " - "=== (removed|added|renamed|modified)" (bzr diff, alternative) | |
3830 | 205 " - "# HG changeset patch" in first line (Mercurial export format) |
206 elseif s:line1 =~ '^\(diff\>\|Only in \|\d\+\(,\d\+\)\=[cda]\d\+\>\|# It was generated by makepatch \|Index:\s\+\f\+\r\=$\|===== \f\+ \d\+\.\d\+ vs edited\|==== //\f\+#\d\+\|# HG changeset patch\)' | |
7 | 207 \ || (s:line1 =~ '^--- ' && s:line2 =~ '^+++ ') |
531 | 208 \ || (s:line1 =~ '^\* looking for ' && s:line2 =~ '^\* comparing to ') |
7 | 209 \ || (s:line1 =~ '^\*\*\* ' && s:line2 =~ '^--- ') |
816 | 210 \ || (s:line1 =~ '^=== ' && ((s:line2 =~ '^=\{66\}' && s:line3 =~ '^--- ' && s:line4 =~ '^+++') || (s:line2 =~ '^--- ' && s:line3 =~ '^+++ '))) |
211 \ || (s:line1 =~ '^=== \(removed\|added\|renamed\|modified\)') | |
7 | 212 set ft=diff |
213 | |
214 " PostScript Files (must have %!PS as the first line, like a2ps output) | |
215 elseif s:line1 =~ '^%![ \t]*PS' | |
216 set ft=postscr | |
217 | |
218 " M4 scripts: Guess there is a line that starts with "dnl". | |
219 elseif s:line1 =~ '^\s*dnl\>' | |
220 \ || s:line2 =~ '^\s*dnl\>' | |
221 \ || s:line3 =~ '^\s*dnl\>' | |
222 \ || s:line4 =~ '^\s*dnl\>' | |
223 \ || s:line5 =~ '^\s*dnl\>' | |
224 set ft=m4 | |
225 | |
226 " AmigaDos scripts | |
227 elseif $TERM == "amiga" | |
228 \ && (s:line1 =~ "^;" || s:line1 =~ '^\.[bB][rR][aA]') | |
229 set ft=amiga | |
230 | |
231 " SiCAD scripts (must have procn or procd as the first line to trigger this) | |
232 elseif s:line1 =~? '^ *proc[nd] *$' | |
233 set ft=sicad | |
234 | |
235 " Purify log files start with "**** Purify" | |
236 elseif s:line1 =~ '^\*\*\*\* Purify' | |
237 set ft=purifylog | |
238 | |
239 " XML | |
240 elseif s:line1 =~ '<?\s*xml.*?>' | |
241 set ft=xml | |
242 | |
243 " XHTML (e.g.: PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN") | |
244 elseif s:line1 =~ '\<DTD\s\+XHTML\s' | |
245 set ft=xhtml | |
246 | |
1708 | 247 " HTML (e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN") |
248 elseif s:line1 =~? '\<DOCTYPE\s\+html\>' | |
249 set ft=html | |
250 | |
1648 | 251 " PDF |
252 elseif s:line1 =~ '^%PDF-' | |
253 set ft=pdf | |
254 | |
7 | 255 " XXD output |
256 elseif s:line1 =~ '^\x\{7}: \x\{2} \=\x\{2} \=\x\{2} \=\x\{2} ' | |
257 set ft=xxd | |
258 | |
259 " RCS/CVS log output | |
260 elseif s:line1 =~ '^RCS file:' || s:line2 =~ '^RCS file:' | |
261 set ft=rcslog | |
262 | |
263 " CVS commit | |
22 | 264 elseif s:line2 =~ '^CVS:' || getline("$") =~ '^CVS: ' |
7 | 265 set ft=cvs |
266 | |
179 | 267 " Prescribe |
268 elseif s:line1 =~ '^!R!' | |
269 set ft=prescribe | |
270 | |
7 | 271 " Send-pr |
272 elseif s:line1 =~ '^SEND-PR:' | |
273 set ft=sendpr | |
274 | |
275 " SNNS files | |
276 elseif s:line1 =~ '^SNNS network definition file' | |
277 set ft=snnsnet | |
278 elseif s:line1 =~ '^SNNS pattern definition file' | |
279 set ft=snnspat | |
280 elseif s:line1 =~ '^SNNS result file' | |
281 set ft=snnsres | |
282 | |
283 " Virata | |
284 elseif s:line1 =~ '^%.\{-}[Vv]irata' | |
285 \ || s:line2 =~ '^%.\{-}[Vv]irata' | |
286 \ || s:line3 =~ '^%.\{-}[Vv]irata' | |
287 \ || s:line4 =~ '^%.\{-}[Vv]irata' | |
288 \ || s:line5 =~ '^%.\{-}[Vv]irata' | |
289 set ft=virata | |
290 | |
291 " Strace | |
1698 | 292 elseif s:line1 =~ '^\(\[pid \d\+\] \)\=[0-9:.]* *execve(' || s:line1 =~ '^__libc_start_main' |
7 | 293 set ft=strace |
294 | |
295 " VSE JCL | |
296 elseif s:line1 =~ '^\* $$ JOB\>' || s:line1 =~ '^// *JOB\>' | |
297 set ft=vsejcl | |
298 | |
299 " TAK and SINDA | |
300 elseif s:line4 =~ 'K & K Associates' || s:line2 =~ 'TAK 2000' | |
301 set ft=takout | |
302 elseif s:line3 =~ 'S Y S T E M S I M P R O V E D ' | |
303 set ft=sindaout | |
304 elseif getline(6) =~ 'Run Date: ' | |
305 set ft=takcmp | |
306 elseif getline(9) =~ 'Node File 1' | |
307 set ft=sindacmp | |
308 | |
309 " DNS zone files | |
807 | 310 elseif s:line1.s:line2.s:line3.s:line4 =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA' |
311 set ft=bindzone | |
7 | 312 |
313 " BAAN | |
314 elseif s:line1 =~ '|\*\{1,80}' && s:line2 =~ 'VRC ' | |
315 \ || s:line2 =~ '|\*\{1,80}' && s:line3 =~ 'VRC ' | |
316 set ft=baan | |
317 | |
318 " Valgrind | |
1145 | 319 elseif s:line1 =~ '^==\d\+== valgrind' || s:line3 =~ '^==\d\+== Using valgrind' |
7 | 320 set ft=valgrind |
321 | |
322 " Renderman Interface Bytestream | |
323 elseif s:line1 =~ '^##RenderMan' | |
324 set ft=rib | |
325 | |
326 " Scheme scripts | |
327 elseif s:line1 =~ 'exec\s\+\S*scheme' || s:line2 =~ 'exec\s\+\S*scheme' | |
328 set ft=scheme | |
329 | |
1648 | 330 " Git output |
2034 | 331 elseif s:line1 =~ '^\(commit\|tree\|object\) \x\{40\}\>\|^tag \S\+$' |
1648 | 332 set ft=git |
333 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
3830
diff
changeset
|
334 " Gprof (gnu profiler) |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
3830
diff
changeset
|
335 elseif s:line1 == 'Flat profile:' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
3830
diff
changeset
|
336 \ && s:line2 == '' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
3830
diff
changeset
|
337 \ && s:line3 =~ '^Each sample counts as .* seconds.$' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
3830
diff
changeset
|
338 set ft=gprof |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
3830
diff
changeset
|
339 |
4780 | 340 " Erlang terms |
341 " (See also: http://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html#Choosing-Modes) | |
342 elseif s:line1 =~? '-\*-.*erlang.*-\*-' | |
343 set ft=erlang | |
344 | |
7 | 345 " CVS diff |
346 else | |
2034 | 347 let s:lnum = 1 |
348 while getline(s:lnum) =~ "^? " && s:lnum < line("$") | |
349 let s:lnum += 1 | |
7 | 350 endwhile |
2034 | 351 if getline(s:lnum) =~ '^Index:\s\+\f\+$' |
7 | 352 set ft=diff |
353 | |
354 " locale input files: Formal Definitions of Cultural Conventions | |
355 " filename must be like en_US, fr_FR@euro or en_US.UTF-8 | |
356 elseif expand("%") =~ '\a\a_\a\a\($\|[.@]\)\|i18n$\|POSIX$\|translit_' | |
2034 | 357 let s:lnum = 1 |
358 while s:lnum < 100 && s:lnum < line("$") | |
359 if getline(s:lnum) =~ '^LC_\(IDENTIFICATION\|CTYPE\|COLLATE\|MONETARY\|NUMERIC\|TIME\|MESSAGES\|PAPER\|TELEPHONE\|MEASUREMENT\|NAME\|ADDRESS\)$' | |
7 | 360 setf fdcc |
361 break | |
362 endif | |
2034 | 363 let s:lnum += 1 |
7 | 364 endwhile |
365 endif | |
2034 | 366 unlet s:lnum |
7 | 367 |
368 endif | |
369 | |
370 unlet s:line2 s:line3 s:line4 s:line5 | |
371 | |
372 endif | |
373 | |
374 " Restore 'cpoptions' | |
375 let &cpo = s:cpo_save | |
376 | |
377 unlet s:cpo_save s:line1 |