Mercurial > vim
annotate runtime/autoload/dist/script.vim @ 32576:5d32f2d42a6b v9.0.1620
patch 9.0.1620: Nix files are not recognized from the hashbang line
Commit: https://github.com/vim/vim/commit/19548c6a742d954ecd0b50b0680c37cc6ced7473
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 8 21:27:13 2023 +0100
patch 9.0.1620: Nix files are not recognized from the hashbang line
Problem: Nix files are not recognized from the hashbang line.
Solution: Add a hashbang check. (issue https://github.com/vim/vim/issues/12507)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 08 Jun 2023 22:30:04 +0200 |
parents | 2a17771529af |
children | c777d71cf397 |
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> |
32576
5d32f2d42a6b
patch 9.0.1620: Nix files are not recognized from the hashbang line
Bram Moolenaar <Bram@vim.org>
parents:
32449
diff
changeset
|
7 # Last Change: 2023 Jun 08 |
27692
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 |
32576
5d32f2d42a6b
patch 9.0.1620: Nix files are not recognized from the hashbang line
Bram Moolenaar <Bram@vim.org>
parents:
32449
diff
changeset
|
47 name = substitute(line1, '^#!\s*\S*[/\\]\(\f\+\).*', '\1', '') |
27692
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 |
31203
8a54e866a5db
patch 9.0.0935: when using dash it may not be recognize as filetype "sh"
Bram Moolenaar <Bram@vim.org>
parents:
29399
diff
changeset
|
56 # Bourne-like shell scripts: bash bash2 dash ksh ksh93 sh |
8a54e866a5db
patch 9.0.0935: when using dash it may not be recognize as filetype "sh"
Bram Moolenaar <Bram@vim.org>
parents:
29399
diff
changeset
|
57 if name =~ '^\(bash\d*\|dash\|ksh\d*\|sh\)\>' |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
74 setl ft=zsh |
27692
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\)\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
78 setl ft=tcl |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
82 setl ft=expect |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
86 setl ft=gnuplot |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
90 setl ft=make |
27692
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]\)' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
94 setl ft=pike |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
98 setl ft=lua |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
102 setl ft=perl |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
106 setl ft=php |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
110 setl ft=python |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
114 setl ft=groovy |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
118 setl ft=raku |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
122 setl ft=ruby |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
126 setl ft=javascript |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
130 setl ft=bc |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
134 setl ft=sed |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
138 setl ft=ocaml |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
142 setl ft=awk |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
146 setl ft=wml |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
150 setl ft=scheme |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
154 setl ft=cfengine |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
158 setl ft=erlang |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
162 setl ft=haskell |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
166 setl ft=scala |
27692
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' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
170 setl ft=clojure |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
174 setl ft=pascal |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
178 setl ft=fennel |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
182 setl ft=routeros |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
186 setl ft=fish |
27692
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\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
190 setl ft=forth |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 |
29181
71759abd2145
patch 8.2.5110: icon filetype not recognized from the first line
Bram Moolenaar <Bram@vim.org>
parents:
27692
diff
changeset
|
192 # Icon |
71759abd2145
patch 8.2.5110: icon filetype not recognized from the first line
Bram Moolenaar <Bram@vim.org>
parents:
27692
diff
changeset
|
193 elseif name =~ 'icon\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
194 setl ft=icon |
29181
71759abd2145
patch 8.2.5110: icon filetype not recognized from the first line
Bram Moolenaar <Bram@vim.org>
parents:
27692
diff
changeset
|
195 |
29399
88d62ab596e8
patch 9.0.0042: missing change for filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
29181
diff
changeset
|
196 # Guile |
88d62ab596e8
patch 9.0.0042: missing change for filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
29181
diff
changeset
|
197 elseif name =~ 'guile' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
198 setl ft=scheme |
29399
88d62ab596e8
patch 9.0.0042: missing change for filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
29181
diff
changeset
|
199 |
32576
5d32f2d42a6b
patch 9.0.1620: Nix files are not recognized from the hashbang line
Bram Moolenaar <Bram@vim.org>
parents:
32449
diff
changeset
|
200 # Nix |
5d32f2d42a6b
patch 9.0.1620: Nix files are not recognized from the hashbang line
Bram Moolenaar <Bram@vim.org>
parents:
32449
diff
changeset
|
201 elseif name =~ 'nix-shell' |
5d32f2d42a6b
patch 9.0.1620: Nix files are not recognized from the hashbang line
Bram Moolenaar <Bram@vim.org>
parents:
32449
diff
changeset
|
202 setl ft=nix |
5d32f2d42a6b
patch 9.0.1620: Nix files are not recognized from the hashbang line
Bram Moolenaar <Bram@vim.org>
parents:
32449
diff
changeset
|
203 |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 endif |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 enddef |
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 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 # 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 # 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
|
216 if line1 =~ '^:$' |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 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
|
218 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 # 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
|
220 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
|
221 || line1 =~ '^#autoload\>' |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 || "\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
|
223 "\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
|
224 =~ '\n\s*emulate\s\+\%(-[LR]\s\+\)\=[ckz]\=sh\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
225 setl ft=zsh |
27692
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 # 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
|
228 elseif line1 =~ '^From \([a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\=\|-\) .* \(19\|20\)\d\d$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
229 setl ft=mail |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 # Mason |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 elseif line1 =~ '^<[%&].*>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
233 setl ft=mason |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 # 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
|
236 elseif line1 =~ '^" *[vV]im$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
237 setl ft=vim |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 # 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
|
240 # 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
|
241 elseif line1 =~? '-\*-.*C++.*-\*-' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
242 setl ft=cpp |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 # MOO |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 elseif line1 =~ '^\*\* LambdaMOO Database, Format Version \%([1-3]\>\)\@!\d\+ \*\*$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
246 setl ft=moo |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 # Diff file: |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 # - "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
|
250 # - "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
|
251 # - "--- " 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
|
252 # - "*** " 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
|
253 # - "# 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
|
254 # - "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
|
255 # - "=== ", 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
|
256 # - "=== ", "--- ", "+++ " (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
|
257 # - "=== (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
|
258 # - "# 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
|
259 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
|
260 || (line1 =~ '^--- ' && line2 =~ '^+++ ') |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 || (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
|
262 || (line1 =~ '^\*\*\* ' && line2 =~ '^--- ') |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 || (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
|
264 || (line1 =~ '^=== \(removed\|added\|renamed\|modified\)') |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
265 setl ft=diff |
27692
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 # 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
|
268 elseif line1 =~ '^%![ \t]*PS' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
269 setl ft=postscr |
27692
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 # 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
|
272 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
|
273 || 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
|
274 || 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
|
275 || 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
|
276 || line5 =~ '^\s*dnl\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
277 setl ft=m4 |
27692
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 # AmigaDos scripts |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 elseif $TERM == "amiga" && (line1 =~ "^;" || line1 =~? '^\.bra') |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
281 setl ft=amiga |
27692
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 # 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
|
284 elseif line1 =~? '^ *proc[nd] *$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
285 setl ft=sicad |
27692
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 # 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
|
288 elseif line1 =~ '^\*\*\*\* Purify' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
289 setl ft=purifylog |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 # XML |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 elseif line1 =~ '<?\s*xml.*?>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
293 setl ft=xml |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 # 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
|
296 elseif line1 =~ '\<DTD\s\+XHTML\s' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
297 setl ft=xhtml |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 # 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
|
300 # 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
|
301 elseif line1 =~? '<!DOCTYPE\s\+html\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
302 setl ft=html |
27692
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 # PDF |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 elseif line1 =~ '^%PDF-' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
306 setl ft=pdf |
27692
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 # XXD output |
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 =~ '^\x\{7}: \x\{2} \=\x\{2} \=\x\{2} \=\x\{2} ' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
310 setl ft=xxd |
27692
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 # 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
|
313 elseif line1 =~ '^RCS file:' || line2 =~ '^RCS file:' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
314 setl ft=rcslog |
27692
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 # CVS commit |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 elseif line2 =~ '^CVS:' || getline("$") =~ '^CVS: ' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
318 setl ft=cvs |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 # Prescribe |
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 =~ '^!R!' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
322 setl ft=prescribe |
27692
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 # Send-pr |
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 =~ '^SEND-PR:' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
326 setl ft=sendpr |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 # SNNS files |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 elseif line1 =~ '^SNNS network definition file' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
330 setl ft=snnsnet |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 elseif line1 =~ '^SNNS pattern definition file' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
332 setl ft=snnspat |
27692
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 =~ '^SNNS result file' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
334 setl ft=snnsres |
27692
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 # Virata |
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 =~ '^%.\{-}[Vv]irata' |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 || 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
|
339 || 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
|
340 || 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
|
341 || line5 =~ '^%.\{-}[Vv]irata' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
342 setl ft=virata |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 # Strace |
32266
769df9d385e0
patch 9.0.1464: strace filetype detection is expensive
Bram Moolenaar <Bram@vim.org>
parents:
31383
diff
changeset
|
345 # inaccurate fast match first, then use accurate slow match |
769df9d385e0
patch 9.0.1464: strace filetype detection is expensive
Bram Moolenaar <Bram@vim.org>
parents:
31383
diff
changeset
|
346 elseif (line1 =~ 'execve(' && line1 =~ '^[0-9:.]* *execve(') |
769df9d385e0
patch 9.0.1464: strace filetype detection is expensive
Bram Moolenaar <Bram@vim.org>
parents:
31383
diff
changeset
|
347 || line1 =~ '^__libc_start_main' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
348 setl ft=strace |
27692
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 # VSE JCL |
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 =~ '^\* $$ JOB\>' || line1 =~ '^// *JOB\>' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
352 setl ft=vsejcl |
27692
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 # 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
|
355 elseif line4 =~ 'K & K Associates' || line2 =~ 'TAK 2000' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
356 setl ft=takout |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 elseif line3 =~ 'S Y S T E M S I M P R O V E D ' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
358 setl ft=sindaout |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 elseif getline(6) =~ 'Run Date: ' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
360 setl ft=takcmp |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 elseif getline(9) =~ 'Node File 1' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
362 setl ft=sindacmp |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 # 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
|
365 elseif line1 .. line2 .. line3 .. line4 =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
366 setl ft=bindzone |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 # BAAN |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 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
|
370 || line2 =~ '|\*\{1,80}' && line3 =~ 'VRC ' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
371 setl ft=baan |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 # Valgrind |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 elseif line1 =~ '^==\d\+== valgrind' || line3 =~ '^==\d\+== Using valgrind' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
375 setl ft=valgrind |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 # Go docs |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 elseif line1 =~ '^PACKAGE DOCUMENTATION$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
379 setl ft=godoc |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 # 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
|
382 elseif line1 =~ '^##RenderMan' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
383 setl ft=rib |
27692
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 # Scheme scripts |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 elseif line1 =~ 'exec\s\+\S*scheme' || line2 =~ 'exec\s\+\S*scheme' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
387 setl ft=scheme |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 # Git output |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 elseif line1 =~ '^\(commit\|tree\|object\) \x\{40,\}\>\|^tag \S\+$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
391 setl ft=git |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 # 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
|
394 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
|
395 && line2 == '' |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 && line3 =~ '^Each sample counts as .* seconds.$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
397 setl ft=gprof |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 # Erlang terms |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 # (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
|
401 elseif line1 =~? '-\*-.*erlang.*-\*-' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
402 setl ft=erlang |
27692
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 # YAML |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 elseif line1 =~ '^%YAML' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
406 setl ft=yaml |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 # 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
|
409 elseif line1 =~ '^#.*by RouterOS.*$' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
410 setl ft=routeros |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 # Sed scripts |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 # #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
|
414 # 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
|
415 elseif line1 =~ '^#n\%($\|\s\)' |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
416 setl ft=sed |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 else |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 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
|
420 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
|
421 lnum += 1 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 endwhile |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 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
|
424 # CVS diff |
32375
009956955aa3
patch 9.0.1519: global 'filetype' is set when detected from file content
Bram Moolenaar <Bram@vim.org>
parents:
32294
diff
changeset
|
425 setl ft=diff |
27692
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 # 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
|
428 # 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
|
429 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
|
430 lnum = 1 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 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
|
432 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
|
433 setf fdcc |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
434 break |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 endif |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 lnum += 1 |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 endwhile |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 endif |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 endif |
7346315e8517
patch 8.2.4372: filetype detection from file contents is in legacy script
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 enddef |