annotate runtime/autoload/dist/script.vim @ 27692:7346315e8517 v8.2.4372

patch 8.2.4372: filetype detection from file contents is in legacy script Commit: https://github.com/vim/vim/commit/299d8e5eec8f8ae91177f7feb67ad59402dfa8e2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 13 20:32:02 2022 +0000 patch 8.2.4372: filetype detection from file contents is in legacy script Problem: Filetype detection from file contents is in legacy script. Solution: Use a compiled function for filetype detection.
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Feb 2022 21:45:02 +0100
parents
children 71759abd2145
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27692
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 vim9script
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 # Vim function for detecting a filetype from the file contents.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 # Invoked from "scripts.vim" in 'runtimepath'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 #
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 # Maintainer: Bram Moolenaar <Bram@vim.org>
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 # Last Change: 2022 Feb 13
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 export def DetectFiletype()
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 var line1 = getline(1)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 if line1[0] == '#' && line1[1] == '!'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 # File that starts with "#!".
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 DetectFromHashBang(line1)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 else
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 # File does not start with "#!".
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 DetectFromText(line1)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 enddef
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 # Called for a script that has "#!" in the first line.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 def DetectFromHashBang(firstline: string)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 var line1 = firstline
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 # Check for a line like "#!/usr/bin/env {options} bash". Turn it into
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 # "#!/usr/bin/bash" to make matching easier.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 # Recognize only a few {options} that are commonly used.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 if line1 =~ '^#!\s*\S*\<env\s'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 line1 = substitute(line1, '\S\+=\S\+', '', 'g')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 line1 = substitute(line1, '\(-[iS]\|--ignore-environment\|--split-string\)', '', '')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 line1 = substitute(line1, '\<env\s\+', '', '')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 # Get the program name.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 # Only accept spaces in PC style paths: "#!c:/program files/perl [args]".
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 # If the word env is used, use the first word after the space:
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 # "#!/usr/bin/env perl [path/args]"
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 # If there is no path use the first word: "#!perl [path/args]".
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 # Otherwise get the last word after a slash: "#!/usr/bin/perl [path/args]".
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 var name: string
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 if line1 =~ '^#!\s*\a:[/\\]'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 name = substitute(line1, '^#!.*[/\\]\(\i\+\).*', '\1', '')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 elseif line1 =~ '^#!.*\<env\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 name = substitute(line1, '^#!.*\<env\>\s\+\(\i\+\).*', '\1', '')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 elseif line1 =~ '^#!\s*[^/\\ ]*\>\([^/\\]\|$\)'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 name = substitute(line1, '^#!\s*\([^/\\ ]*\>\).*', '\1', '')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 else
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 name = substitute(line1, '^#!\s*\S*[/\\]\(\i\+\).*', '\1', '')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 # tcl scripts may have #!/bin/sh in the first line and "exec wish" in the
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 # third line. Suggested by Steven Atkinson.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 if getline(3) =~ '^exec wish'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 name = 'wish'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 # Bourne-like shell scripts: bash bash2 ksh ksh93 sh
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 if name =~ '^\(bash\d*\|\|ksh\d*\|sh\)\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 call dist#ft#SetFileTypeSH(line1)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 # csh scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 elseif name =~ '^csh\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 if exists("g:filetype_csh")
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 call dist#ft#SetFileTypeShell(g:filetype_csh)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 else
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 call dist#ft#SetFileTypeShell("csh")
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 # tcsh scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 elseif name =~ '^tcsh\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 call dist#ft#SetFileTypeShell("tcsh")
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 # Z shell scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 elseif name =~ '^zsh\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 set ft=zsh
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 # TCL scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 elseif name =~ '^\(tclsh\|wish\|expectk\|itclsh\|itkwish\)\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 set ft=tcl
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 # Expect scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 elseif name =~ '^expect\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 set ft=expect
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 # Gnuplot scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 elseif name =~ '^gnuplot\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 set ft=gnuplot
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 # Makefiles
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 elseif name =~ 'make\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 set ft=make
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 # Pike
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 elseif name =~ '^pike\%(\>\|[0-9]\)'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 set ft=pike
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 # Lua
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 elseif name =~ 'lua'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 set ft=lua
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 # Perl
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 elseif name =~ 'perl'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 set ft=perl
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 # PHP
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 elseif name =~ 'php'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 set ft=php
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 # Python
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 elseif name =~ 'python'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 set ft=python
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 # Groovy
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 elseif name =~ '^groovy\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 set ft=groovy
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 # Raku
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 elseif name =~ 'raku'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 set ft=raku
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 # Ruby
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 elseif name =~ 'ruby'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 set ft=ruby
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 # JavaScript
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 elseif name =~ 'node\(js\)\=\>\|js\>' || name =~ 'rhino\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 set ft=javascript
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 # BC calculator
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 elseif name =~ '^bc\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 set ft=bc
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 # sed
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 elseif name =~ 'sed\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 set ft=sed
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 # OCaml-scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 elseif name =~ 'ocaml'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 set ft=ocaml
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 # Awk scripts; also finds "gawk"
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 elseif name =~ 'awk\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 set ft=awk
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 # Website MetaLanguage
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 elseif name =~ 'wml'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 set ft=wml
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 # Scheme scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 elseif name =~ 'scheme'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 set ft=scheme
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 # CFEngine scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 elseif name =~ 'cfengine'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 set ft=cfengine
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 # Erlang scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 elseif name =~ 'escript'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 set ft=erlang
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 # Haskell
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 elseif name =~ 'haskell'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 set ft=haskell
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 # Scala
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 elseif name =~ 'scala\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 set ft=scala
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 # Clojure
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 elseif name =~ 'clojure'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 set ft=clojure
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 # Free Pascal
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 elseif name =~ 'instantfpc\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 set ft=pascal
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 # Fennel
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 elseif name =~ 'fennel\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 set ft=fennel
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 # MikroTik RouterOS script
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 elseif name =~ 'rsc\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 set ft=routeros
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 # Fish shell
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 elseif name =~ 'fish\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 set ft=fish
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 # Gforth
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 elseif name =~ 'gforth\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 set ft=forth
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 enddef
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 # Called for a script that does not have "#!" in the first line.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 def DetectFromText(line1: string)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 var line2 = getline(2)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 var line3 = getline(3)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 var line4 = getline(4)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 var line5 = getline(5)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 # Bourne-like shell scripts: sh ksh bash bash2
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 if line1 =~ '^:$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 call dist#ft#SetFileTypeSH(line1)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 # Z shell scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 elseif line1 =~ '^#compdef\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 || line1 =~ '^#autoload\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 || "\n" .. line1 .. "\n" .. line2 .. "\n" .. line3 ..
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 "\n" .. line4 .. "\n" .. line5
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 =~ '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 set ft=zsh
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 # ELM Mail files
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 elseif line1 =~ '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 set ft=mail
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 # Mason
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 elseif line1 =~ '^<[%&].*>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 set ft=mason
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 # Vim scripts (must have '" vim' as the first line to trigger this)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 elseif line1 =~ '^" *[vV]im$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 set ft=vim
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 # libcxx and libstdc++ standard library headers like "iostream" do not have
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 # an extension, recognize the Emacs file mode.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 elseif line1 =~? '-\*-.*C++.*-\*-'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 set ft=cpp
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 # MOO
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 elseif line1 =~ '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 set ft=moo
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 # Diff file:
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 # - "diff" in first line (context diff)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 # - "Only in " in first line
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 # - "--- " in first line and "+++ " in second line (unified diff).
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 # - "*** " in first line and "--- " in second line (context diff).
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 # - "# It was generated by makepatch " in the second line (makepatch diff).
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 # - "Index: <filename>" in the first line (CVS file)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 # - "=== ", line of "=", "---", "+++ " (SVK diff)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 # - "=== ", "--- ", "+++ " (bzr diff, common case)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 # - "=== (removed|added|renamed|modified)" (bzr diff, alternative)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 # - "# HG changeset patch" in first line (Mercurial export format)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 elseif 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\)'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 || (line1 =~ '^--- ' && line2 =~ '^+++ ')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 || (line1 =~ '^\* looking for ' && line2 =~ '^\* comparing to ')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 || (line1 =~ '^\*\*\* ' && line2 =~ '^--- ')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 || (line1 =~ '^=== ' && ((line2 =~ '^=\{66\}' && line3 =~ '^--- ' && line4 =~ '^+++') || (line2 =~ '^--- ' && line3 =~ '^+++ ')))
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 || (line1 =~ '^=== \(removed\|added\|renamed\|modified\)')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 set ft=diff
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 # PostScript Files (must have %!PS as the first line, like a2ps output)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 elseif line1 =~ '^%![ \t]*PS'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 set ft=postscr
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 # M4 scripts: Guess there is a line that starts with "dnl".
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 elseif line1 =~ '^\s*dnl\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 || line2 =~ '^\s*dnl\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 || line3 =~ '^\s*dnl\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 || line4 =~ '^\s*dnl\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 || line5 =~ '^\s*dnl\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 set ft=m4
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 # AmigaDos scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 elseif $TERM == "amiga" && (line1 =~ "^;" || line1 =~? '^\.bra')
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 set ft=amiga
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 # SiCAD scripts (must have procn or procd as the first line to trigger this)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 elseif line1 =~? '^ *proc[nd] *$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 set ft=sicad
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 # Purify log files start with "**** Purify"
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 elseif line1 =~ '^\*\*\*\* Purify'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 set ft=purifylog
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 # XML
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 elseif line1 =~ '<?\s*xml.*?>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 set ft=xml
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 # XHTML (e.g.: PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN")
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 elseif line1 =~ '\<DTD\s\+XHTML\s'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 set ft=xhtml
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 # HTML (e.g.: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN")
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 # Avoid "doctype html", used by slim.
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 elseif line1 =~? '<!DOCTYPE\s\+html\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 set ft=html
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 # PDF
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 elseif line1 =~ '^%PDF-'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 set ft=pdf
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 # XXD output
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 elseif line1 =~ '^\x\{7}: \x\{2} \=\x\{2} \=\x\{2} \=\x\{2} '
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 set ft=xxd
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 # RCS/CVS log output
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 elseif line1 =~ '^RCS file:' || line2 =~ '^RCS file:'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 set ft=rcslog
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 # CVS commit
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 elseif line2 =~ '^CVS:' || getline("$") =~ '^CVS: '
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 set ft=cvs
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 # Prescribe
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 elseif line1 =~ '^!R!'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 set ft=prescribe
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 # Send-pr
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 elseif line1 =~ '^SEND-PR:'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314 set ft=sendpr
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 # SNNS files
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 elseif line1 =~ '^SNNS network definition file'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 set ft=snnsnet
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 elseif line1 =~ '^SNNS pattern definition file'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 set ft=snnspat
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 elseif line1 =~ '^SNNS result file'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 set ft=snnsres
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 # Virata
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 elseif line1 =~ '^%.\{-}[Vv]irata'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 || line2 =~ '^%.\{-}[Vv]irata'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 || line3 =~ '^%.\{-}[Vv]irata'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 || line4 =~ '^%.\{-}[Vv]irata'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 || line5 =~ '^%.\{-}[Vv]irata'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 set ft=virata
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 # Strace
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 elseif line1 =~ '[0-9:.]* *execve(' || line1 =~ '^__libc_start_main'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 set ft=strace
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 # VSE JCL
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 elseif line1 =~ '^\* $$ JOB\>' || line1 =~ '^// *JOB\>'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338 set ft=vsejcl
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 # TAK and SINDA
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 elseif line4 =~ 'K & K Associates' || line2 =~ 'TAK 2000'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 set ft=takout
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 elseif line3 =~ 'S Y S T E M S I M P R O V E D '
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 set ft=sindaout
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 elseif getline(6) =~ 'Run Date: '
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 set ft=takcmp
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 elseif getline(9) =~ 'Node File 1'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 set ft=sindacmp
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 # DNS zone files
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 elseif line1 .. line2 .. line3 .. line4 =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 set ft=bindzone
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 # BAAN
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 elseif line1 =~ '|\*\{1,80}' && line2 =~ 'VRC '
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 || line2 =~ '|\*\{1,80}' && line3 =~ 'VRC '
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 set ft=baan
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 # Valgrind
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
360 elseif line1 =~ '^==\d\+== valgrind' || line3 =~ '^==\d\+== Using valgrind'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 set ft=valgrind
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
362
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 # Go docs
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
364 elseif line1 =~ '^PACKAGE DOCUMENTATION$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 set ft=godoc
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
366
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 # Renderman Interface Bytestream
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 elseif line1 =~ '^##RenderMan'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 set ft=rib
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 # Scheme scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 elseif line1 =~ 'exec\s\+\S*scheme' || line2 =~ 'exec\s\+\S*scheme'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
373 set ft=scheme
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 # Git output
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 elseif line1 =~ '^\(commit\|tree\|object\) \x\{40,\}\>\|^tag \S\+$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
377 set ft=git
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
378
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
379 # Gprof (gnu profiler)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 elseif line1 == 'Flat profile:'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 && line2 == ''
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 && line3 =~ '^Each sample counts as .* seconds.$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 set ft=gprof
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 # Erlang terms
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 # (See also: http://www.gnu.org/software/emacs/manual/html_node/emacs/Choosing-Modes.html#Choosing-Modes)
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 elseif line1 =~? '-\*-.*erlang.*-\*-'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 set ft=erlang
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 # YAML
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 elseif line1 =~ '^%YAML'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 set ft=yaml
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 # MikroTik RouterOS script
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 elseif line1 =~ '^#.*by RouterOS.*$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 set ft=routeros
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 # Sed scripts
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 # #ncomment is allowed but most likely a false positive so require a space
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 # before any trailing comment text
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 elseif line1 =~ '^#n\%($\|\s\)'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 set ft=sed
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 else
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 var lnum = 1
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 while getline(lnum) =~ "^? " && lnum < line("$")
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 lnum += 1
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 endwhile
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 if getline(lnum) =~ '^Index:\s\+\f\+$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 # CVS diff
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 set ft=diff
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 # locale input files: Formal Definitions of Cultural Conventions
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 # filename must be like en_US, fr_FR@euro or en_US.UTF-8
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 elseif expand("%") =~ '\a\a_\a\a\($\|[.@]\)\|i18n$\|POSIX$\|translit_'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 lnum = 1
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 while lnum < 100 && lnum < line("$")
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 if getline(lnum) =~ '^LC_\(IDENTIFICATION\|CTYPE\|COLLATE\|MONETARY\|NUMERIC\|TIME\|MESSAGES\|PAPER\|TELEPHONE\|MEASUREMENT\|NAME\|ADDRESS\)$'
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 setf fdcc
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 break
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 lnum += 1
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 endwhile
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 endif
7346315e8517 patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 enddef