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