Mercurial > vim
annotate runtime/autoload/dist/ft.vim @ 27162:b19230a8d40a
Update runtime files
Commit: https://github.com/vim/vim/commit/fd31be29b8220ee1cb0b3460c82f2634ae3cc370
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 16 14:46:06 2022 +0000
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 16 Jan 2022 16:00:06 +0100 |
parents | b353bd9faec8 |
children | 9f72ec92d361 |
rev | line source |
---|---|
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Vim functions for file type detection |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Maintainer: Bram Moolenaar <Bram@vim.org> |
27162 | 4 " Last Change: 2022 Jan 11 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 " These functions are moved here from runtime/filetype.vim to make startup |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 " faster. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 " Line continuation is used here, remove 'C' from 'cpoptions' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 let s:cpo_save = &cpo |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 set cpo&vim |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 func dist#ft#Check_inp() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 if getline(1) =~ '^\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 setf abaqus |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 let n = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 if line("$") > 500 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 let nmax = 500 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 let nmax = line("$") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 while n <= nmax |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 if getline(n) =~? "^header surface data" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 setf trasys |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 " This function checks for the kind of assembly that is wanted by the user, or |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 " can be detected from the first five lines of the file. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 func dist#ft#FTasm() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 " make sure b:asmsyntax exists |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 if !exists("b:asmsyntax") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 let b:asmsyntax = "" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 if b:asmsyntax == "" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 call dist#ft#FTasmsyntax() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 " if b:asmsyntax still isn't set, default to asmsyntax or GNU |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 if b:asmsyntax == "" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 if exists("g:asmsyntax") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 let b:asmsyntax = g:asmsyntax |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 let b:asmsyntax = "asm" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 exe "setf " . fnameescape(b:asmsyntax) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 func dist#ft#FTasmsyntax() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 " see if file contains any asmsyntax=foo overrides. If so, change |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 " b:asmsyntax appropriately |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 \" ".getline(5)." " |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 if match != '' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 let b:asmsyntax = match |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 let b:asmsyntax = "vmasm" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 " Check if one of the first five lines contains "VB_Name". In that case it is |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 " probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 func dist#ft#FTVB(alt) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 setf vb |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 exe "setf " . a:alt |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 func dist#ft#FTbtm() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 setf dosbatch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 setf btm |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 func dist#ft#BindzoneCheck(default) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 setf bindzone |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 elseif a:default != '' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 exe 'setf ' . a:default |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 func dist#ft#FTlpc() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 if exists("g:lpc_syntax_for_c") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 let lnum = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 while lnum <= 12 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 setf lpc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 let lnum = lnum + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 setf c |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 func dist#ft#FTheader() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 if exists("g:c_syntax_for_h") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 setf objc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 setf objcpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 elseif exists("g:c_syntax_for_h") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 setf c |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 elseif exists("g:ch_syntax_for_h") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 setf ch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
121 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 setf cpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 " This function checks if one of the first ten lines start with a '@'. In |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 " that case it is probably a change file. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 " If the first line starts with # or ! it's probably a ch file. |
14999 | 129 " If a line has "main", "include", "//" or "/*" it's probably ch. |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
130 " Otherwise CHILL is assumed. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
131 func dist#ft#FTchange() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
132 let lnum = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
133 while lnum <= 10 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
134 if getline(lnum)[0] == '@' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
135 setf change |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
136 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
137 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
138 if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
139 setf ch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
140 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 if getline(lnum) =~ "MODULE" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 setf chill |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
145 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
146 if getline(lnum) =~ 'main\s*(\|#\s*include\|//' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
147 setf ch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
148 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
149 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
150 let lnum = lnum + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
151 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
152 setf chill |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
153 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
154 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
155 func dist#ft#FTent() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
156 " This function checks for valid cl syntax in the first five lines. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
157 " Look for either an opening comment, '#', or a block start, '{". |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
158 " If not found, assume SGML. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
159 let lnum = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 while lnum < 6 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
161 let line = getline(lnum) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
162 if line =~ '^\s*[#{]' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 setf cl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
164 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 elseif line !~ '^\s*$' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 " Not a blank line, not a comment, and not a block start, |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
167 " so doesn't look like valid cl code. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 let lnum = lnum + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
171 endw |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 setf dtd |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
173 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 |
25026
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
175 func dist#ft#ExCheck() |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
176 let lines = getline(1, min([line("$"), 100])) |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
177 if exists('g:filetype_euphoria') |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
178 exe 'setf ' . g:filetype_euphoria |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
179 elseif match(lines, '^--\|^ifdef\>\|^include\>') > -1 |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
180 setf euphoria3 |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
181 else |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
182 setf elixir |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
183 endif |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
184 endfunc |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
185 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 func dist#ft#EuphoriaCheck() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 if exists('g:filetype_euphoria') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 exe 'setf ' . g:filetype_euphoria |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
189 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
190 setf euphoria3 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
191 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
192 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
193 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
194 func dist#ft#DtraceCheck() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
195 let lines = getline(1, min([line("$"), 100])) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 if match(lines, '^module\>\|^import\>') > -1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 " D files often start with a module and/or import statement. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 setf d |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 setf dtrace |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
202 setf d |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
206 func dist#ft#FTe() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 if exists('g:filetype_euphoria') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 exe 'setf ' . g:filetype_euphoria |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
210 let n = 1 |
16024
7fd3a9eaeedb
patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
15527
diff
changeset
|
211 while n < 100 && n <= line("$") |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
213 setf specman |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
216 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
218 setf eiffel |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
219 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
220 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
221 |
26311
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
222 " Distinguish between Forth and F#. |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
223 " Provided by Doug Kearns. |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
224 func dist#ft#FTfs() |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
225 if exists("g:filetype_fs") |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
226 exe "setf " . g:filetype_fs |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
227 else |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
228 let line = getline(nextnonblank(1)) |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
229 " comments and colon definitions |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
230 if line =~ '^\s*\.\=( ' || line =~ '^\s*\\G\= ' || line =~ '^\\$' |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
231 \ || line =~ '^\s*: \S' |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
232 setf forth |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
233 else |
26344
36f3a77e4b8c
patch 8.2.3703: most people call F# "fsharp" and not "fs"
Bram Moolenaar <Bram@vim.org>
parents:
26311
diff
changeset
|
234 setf fsharp |
26311
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
235 endif |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
236 endif |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
237 endfunc |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
238 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
239 " Distinguish between HTML, XHTML and Django |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
240 func dist#ft#FThtml() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
241 let n = 1 |
16024
7fd3a9eaeedb
patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
15527
diff
changeset
|
242 while n < 10 && n <= line("$") |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
243 if getline(n) =~ '\<DTD\s\+XHTML\s' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
244 setf xhtml |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
245 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
246 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
247 if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
248 setf htmldjango |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
249 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
251 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
252 endwhile |
16024
7fd3a9eaeedb
patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
15527
diff
changeset
|
253 setf FALLBACK html |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
255 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 " Distinguish between standard IDL and MS-IDL |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
257 func dist#ft#FTidl() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 let n = 1 |
16024
7fd3a9eaeedb
patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
15527
diff
changeset
|
259 while n < 50 && n <= line("$") |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 setf msidl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
262 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
264 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
265 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
266 setf idl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
267 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
268 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
269 " Distinguish between "default" and Cproto prototype file. */ |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
270 func dist#ft#ProtoCheck(default) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
271 " Cproto files have a comment in the first line and a function prototype in |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 " the second line, it always ends in ";". Indent files may also have |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
273 " comments, thus we can't match comments to see the difference. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
274 " IDL files can have a single ';' in the second line, require at least one |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
275 " chacter before the ';'. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
276 if getline(2) =~ '.;$' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 setf cpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
278 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
279 exe 'setf ' . a:default |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
283 func dist#ft#FTm() |
25727
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
284 if exists("g:filetype_m") |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
285 exe "setf " . g:filetype_m |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
286 return |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
287 endif |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
288 |
25794
374adc90efa5
patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25727
diff
changeset
|
289 " excluding end(for|function|if|switch|while) common to Murphi |
374adc90efa5
patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25727
diff
changeset
|
290 let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>' |
25727
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
291 |
26296
9f32ccdadd22
patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents:
25794
diff
changeset
|
292 let objc_preprocessor = '^\s*#\s*\%(import\|include\|define\|if\|ifn\=def\|undef\|line\|error\|pragma\)\>' |
9f32ccdadd22
patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents:
25794
diff
changeset
|
293 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
294 let n = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
295 let saw_comment = 0 " Whether we've seen a multiline comment leader. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
296 while n < 100 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
297 let line = getline(n) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
298 if line =~ '^\s*/\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
299 " /* ... */ is a comment in Objective C and Murphi, so we can't conclude |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
300 " it's either of them yet, but track this as a hint in case we don't see |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
301 " anything more definitive. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
302 let saw_comment = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
303 endif |
26296
9f32ccdadd22
patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents:
25794
diff
changeset
|
304 if line =~ '^\s*//' || line =~ '^\s*@import\>' || line =~ objc_preprocessor |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
305 setf objc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
306 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 endif |
25794
374adc90efa5
patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25727
diff
changeset
|
308 if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' || |
25727
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
309 \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
310 setf octave |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
311 return |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
312 endif |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
313 " TODO: could be Matlab or Octave |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
314 if line =~ '^\s*%' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
315 setf matlab |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
316 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
317 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
318 if line =~ '^\s*(\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
319 setf mma |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
320 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
321 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
322 if line =~ '^\c\s*\(\(type\|var\)\>\|--\)' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
323 setf murphi |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
324 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
325 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
326 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
327 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
328 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
329 if saw_comment |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
330 " We didn't see anything definitive, but this looks like either Objective C |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
331 " or Murphi based on the comment leader. Assume the former as it is more |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
332 " common. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
333 setf objc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
334 else |
25727
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
335 " Default is Matlab |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
336 setf matlab |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
337 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
338 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
339 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
340 func dist#ft#FTmms() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
341 let n = 1 |
19039
d20ed2e5a776
Update a few runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
16086
diff
changeset
|
342 while n < 20 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
343 let line = getline(n) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
344 if line =~ '^\s*\(%\|//\)' || line =~ '^\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
345 setf mmix |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
346 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
347 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
348 if line =~ '^\s*#' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
349 setf make |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
350 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
351 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
352 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
353 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
354 setf mmix |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
355 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
356 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
357 " This function checks if one of the first five lines start with a dot. In |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
358 " that case it is probably an nroff file: 'filetype' is set and 1 is returned. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
359 func dist#ft#FTnroff() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
360 if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
361 setf nroff |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
362 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
363 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
364 return 0 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
365 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
366 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
367 func dist#ft#FTmm() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
368 let n = 1 |
19968 | 369 while n < 20 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
370 let line = getline(n) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
371 if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
372 setf objcpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
373 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
374 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
375 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
376 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
377 setf nroff |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
378 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
379 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
380 func dist#ft#FTpl() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
381 if exists("g:filetype_pl") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
382 exe "setf " . g:filetype_pl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
383 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
384 " recognize Prolog by specific text in the first non-empty line |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
385 " require a blank after the '%' because Perl uses "%list" and "%translate" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
386 let l = getline(nextnonblank(1)) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
387 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
388 setf prolog |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
389 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
390 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
391 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
392 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
393 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
394 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
395 func dist#ft#FTinc() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
396 if exists("g:filetype_inc") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
397 exe "setf " . g:filetype_inc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
398 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
399 let lines = getline(1).getline(2).getline(3) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
400 if lines =~? "perlscript" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
401 setf aspperl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
402 elseif lines =~ "<%" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
403 setf aspvbs |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
404 elseif lines =~ "<?" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
405 setf php |
23584
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
406 " Pascal supports // comments but they're vary rarely used for file |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
407 " headers so assume POV-Ray |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
408 elseif lines =~ '^\s*\%({\|(\*\)' || lines =~? s:ft_pascal_keywords |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
409 setf pascal |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
410 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
411 call dist#ft#FTasmsyntax() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
412 if exists("b:asmsyntax") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
413 exe "setf " . fnameescape(b:asmsyntax) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
414 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
415 setf pov |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
416 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
417 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
418 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
419 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
420 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
421 func dist#ft#FTprogress_cweb() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
422 if exists("g:filetype_w") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
423 exe "setf " . g:filetype_w |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
424 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
425 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
426 if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
427 setf progress |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
428 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
429 setf cweb |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
430 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
431 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
432 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
433 func dist#ft#FTprogress_asm() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
434 if exists("g:filetype_i") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
435 exe "setf " . g:filetype_i |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
436 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
437 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
438 " This function checks for an assembly comment the first ten lines. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
439 " If not found, assume Progress. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
440 let lnum = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
441 while lnum <= 10 && lnum < line('$') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
442 let line = getline(lnum) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
443 if line =~ '^\s*;' || line =~ '^\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
444 call dist#ft#FTasm() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
445 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
446 elseif line !~ '^\s*$' || line =~ '^/\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
447 " Not an empty line: Doesn't look like valid assembly code. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
448 " Or it looks like a Progress /* comment |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
449 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
450 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
451 let lnum = lnum + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
452 endw |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
453 setf progress |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
454 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
455 |
23584
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
456 let s:ft_pascal_comments = '^\s*\%({\|(\*\|//\)' |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
457 let s:ft_pascal_keywords = '^\s*\%(program\|unit\|library\|uses\|begin\|procedure\|function\|const\|type\|var\)\>' |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
458 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
459 func dist#ft#FTprogress_pascal() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
460 if exists("g:filetype_p") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
461 exe "setf " . g:filetype_p |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
462 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
463 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
464 " This function checks for valid Pascal syntax in the first ten lines. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
465 " Look for either an opening comment or a program start. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
466 " If not found, assume Progress. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
467 let lnum = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
468 while lnum <= 10 && lnum < line('$') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
469 let line = getline(lnum) |
23584
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
470 if line =~ s:ft_pascal_comments || line =~? s:ft_pascal_keywords |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
471 setf pascal |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
472 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
473 elseif line !~ '^\s*$' || line =~ '^/\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
474 " Not an empty line: Doesn't look like valid Pascal code. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
475 " Or it looks like a Progress /* comment |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
476 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
477 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
478 let lnum = lnum + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
479 endw |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
480 setf progress |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
481 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
482 |
23584
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
483 func dist#ft#FTpp() |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
484 if exists("g:filetype_pp") |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
485 exe "setf " . g:filetype_pp |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
486 else |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
487 let line = getline(nextnonblank(1)) |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
488 if line =~ s:ft_pascal_comments || line =~? s:ft_pascal_keywords |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
489 setf pascal |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
490 else |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
491 setf puppet |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
492 endif |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
493 endif |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
494 endfunc |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
495 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
496 func dist#ft#FTr() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
497 let max = line("$") > 50 ? 50 : line("$") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
498 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
499 for n in range(1, max) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
500 " Rebol is easy to recognize, check for that first |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
501 if getline(n) =~? '\<REBOL\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
502 setf rebol |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
503 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
504 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
505 endfor |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
506 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
507 for n in range(1, max) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
508 " R has # comments |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
509 if getline(n) =~ '^\s*#' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
510 setf r |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
511 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
512 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
513 " Rexx has /* comments */ |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
514 if getline(n) =~ '^\s*/\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
515 setf rexx |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
516 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
517 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
518 endfor |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
519 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
520 " Nothing recognized, use user default or assume Rexx |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
521 if exists("g:filetype_r") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
522 exe "setf " . g:filetype_r |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
523 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
524 " Rexx used to be the default, but R appears to be much more popular. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
525 setf r |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
526 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
527 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
528 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
529 func dist#ft#McSetf() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
530 " Rely on the file to start with a comment. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
531 " MS message text files use ';', Sendmail files use '#' or 'dnl' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
532 for lnum in range(1, min([line("$"), 20])) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
533 let line = getline(lnum) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
534 if line =~ '^\s*\(#\|dnl\)' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
535 setf m4 " Sendmail .mc file |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
536 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
537 elseif line =~ '^\s*;' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
538 setf msmessages " MS Message text file |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
539 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
540 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
541 endfor |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
542 setf m4 " Default: Sendmail .mc file |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
543 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
544 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
545 " Called from filetype.vim and scripts.vim. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
546 func dist#ft#SetFileTypeSH(name) |
15527
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
547 if did_filetype() |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
548 " Filetype was already detected |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
549 return |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
550 endif |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
551 if expand("<amatch>") =~ g:ft_ignore_pat |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
552 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
553 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
554 if a:name =~ '\<csh\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
555 " Some .sh scripts contain #!/bin/csh. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
556 call dist#ft#SetFileTypeShell("csh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
557 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
558 elseif a:name =~ '\<tcsh\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
559 " Some .sh scripts contain #!/bin/tcsh. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
560 call dist#ft#SetFileTypeShell("tcsh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
561 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
562 elseif a:name =~ '\<zsh\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
563 " Some .sh scripts contain #!/bin/zsh. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
564 call dist#ft#SetFileTypeShell("zsh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
565 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
566 elseif a:name =~ '\<ksh\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
567 let b:is_kornshell = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
568 if exists("b:is_bash") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
569 unlet b:is_bash |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
570 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
571 if exists("b:is_sh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
572 unlet b:is_sh |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
573 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
574 elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
575 let b:is_bash = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
576 if exists("b:is_kornshell") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
577 unlet b:is_kornshell |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
578 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
579 if exists("b:is_sh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
580 unlet b:is_sh |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
581 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
582 elseif a:name =~ '\<sh\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
583 let b:is_sh = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
584 if exists("b:is_kornshell") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
585 unlet b:is_kornshell |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
586 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
587 if exists("b:is_bash") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
588 unlet b:is_bash |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
589 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
590 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
591 call dist#ft#SetFileTypeShell("sh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
592 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
593 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
594 " For shell-like file types, check for an "exec" command hidden in a comment, |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
595 " as used for Tcl. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
596 " Also called from scripts.vim, thus can't be local to this script. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
597 func dist#ft#SetFileTypeShell(name) |
15527
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
598 if did_filetype() |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
599 " Filetype was already detected |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
600 return |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
601 endif |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
602 if expand("<amatch>") =~ g:ft_ignore_pat |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
603 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
604 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
605 let l = 2 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
606 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
607 " Skip empty and comment lines. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
608 let l = l + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
609 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
610 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
611 " Found an "exec" line after a comment with continuation |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
612 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
613 if n =~ '\<tclsh\|\<wish' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
614 setf tcl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
615 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
616 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
617 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
618 exe "setf " . a:name |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
619 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
620 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
621 func dist#ft#CSH() |
15527
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
622 if did_filetype() |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
623 " Filetype was already detected |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
624 return |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
625 endif |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
626 if exists("g:filetype_csh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
627 call dist#ft#SetFileTypeShell(g:filetype_csh) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
628 elseif &shell =~ "tcsh" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
629 call dist#ft#SetFileTypeShell("tcsh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
630 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
631 call dist#ft#SetFileTypeShell("csh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
632 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
633 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
634 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
635 let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
636 func dist#ft#FTRules() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
637 let path = expand('<amatch>:p') |
21853
aab3fe874b05
patch 8.2.1476: filetype test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents:
21849
diff
changeset
|
638 if path =~ '/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|\%(usr/\)\=lib/udev/\%(rules\.d/\)\=.*\.rules\)$' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
639 setf udevrules |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
640 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
641 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
642 if path =~ '^/etc/ufw/' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
643 setf conf " Better than hog |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
644 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
645 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
646 if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
647 setf javascript |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
648 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
649 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
650 try |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
651 let config_lines = readfile('/etc/udev/udev.conf') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
652 catch /^Vim\%((\a\+)\)\=:E484/ |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
653 setf hog |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
654 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
655 endtry |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
656 let dir = expand('<amatch>:p:h') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
657 for line in config_lines |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
658 if line =~ s:ft_rules_udev_rules_pattern |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
659 let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
660 if dir == udev_rules |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
661 setf udevrules |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
662 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
663 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
664 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
665 endfor |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
666 setf hog |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
667 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
668 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
669 func dist#ft#SQL() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
670 if exists("g:filetype_sql") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
671 exe "setf " . g:filetype_sql |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
672 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
673 setf sql |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
674 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
675 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
676 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
677 " If the file has an extension of 't' and is in a directory 't' or 'xt' then |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
678 " it is almost certainly a Perl test file. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
679 " If the first line starts with '#' and contains 'perl' it's probably a Perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
680 " file. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
681 " (Slow test) If a file contains a 'use' statement then it is almost certainly |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
682 " a Perl file. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
683 func dist#ft#FTperl() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
684 let dirname = expand("%:p:h:t") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
685 if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
686 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
687 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
688 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
689 if getline(1)[0] == '#' && getline(1) =~ 'perl' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
690 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
691 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
692 endif |
13051 | 693 let save_cursor = getpos('.') |
694 call cursor(1,1) | |
695 let has_use = search('^use\s\s*\k', 'c', 30) | |
696 call setpos('.', save_cursor) | |
697 if has_use | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
698 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
699 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
700 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
701 return 0 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
702 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
703 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
704 " Choose context, plaintex, or tex (LaTeX) based on these rules: |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
705 " 1. Check the first line of the file for "%&<format>". |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
706 " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. |
14668 | 707 " 3. Default to "plain" or to g:tex_flavor, can be set in user's vimrc. |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
708 func dist#ft#FTtex() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
709 let firstline = getline(1) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
710 if firstline =~ '^%&\s*\a\+' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
711 let format = tolower(matchstr(firstline, '\a\+')) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
712 let format = substitute(format, 'pdf', '', '') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
713 if format == 'tex' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
714 let format = 'latex' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
715 elseif format == 'plaintex' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
716 let format = 'plain' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
717 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
718 elseif expand('%') =~ 'tex/context/.*/.*.tex' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
719 let format = 'context' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
720 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
721 " Default value, may be changed later: |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
722 let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
723 " Save position, go to the top of the file, find first non-comment line. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
724 let save_cursor = getpos('.') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
725 call cursor(1,1) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
726 let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
727 if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
728 let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
729 let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
730 let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
731 \ 'cnp', firstNC + 1000) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
732 if kwline == 1 " lpat matched |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
733 let format = 'latex' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
734 elseif kwline == 2 " cpat matched |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
735 let format = 'context' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
736 endif " If neither matched, keep default set above. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
737 " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
738 " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
739 " if cline > 0 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
740 " let format = 'context' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
741 " endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
742 " if lline > 0 && (cline == 0 || cline > lline) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
743 " let format = 'tex' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
744 " endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
745 endif " firstNC |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
746 call setpos('.', save_cursor) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
747 endif " firstline =~ '^%&\s*\a\+' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
748 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
749 " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
750 if format == 'plain' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
751 setf plaintex |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
752 elseif format == 'context' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
753 setf context |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
754 else " probably LaTeX |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
755 setf tex |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
756 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
757 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
758 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
759 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
760 func dist#ft#FTxml() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
761 let n = 1 |
16024
7fd3a9eaeedb
patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
15527
diff
changeset
|
762 while n < 100 && n <= line("$") |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
763 let line = getline(n) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
764 " DocBook 4 or DocBook 5. |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
765 let is_docbook4 = line =~ '<!DOCTYPE.*DocBook' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
766 let is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
767 if is_docbook4 || is_docbook5 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
768 let b:docbk_type = "xml" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
769 if is_docbook5 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
770 let b:docbk_ver = 5 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
771 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
772 let b:docbk_ver = 4 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
773 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
774 setf docbk |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
775 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
776 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
777 if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
778 setf xbl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
779 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
780 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
781 let n += 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
782 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
783 setf xml |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
784 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
785 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
786 func dist#ft#FTy() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
787 let n = 1 |
16024
7fd3a9eaeedb
patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
15527
diff
changeset
|
788 while n < 100 && n <= line("$") |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
789 let line = getline(n) |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
790 if line =~ '^\s*%' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
791 setf yacc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
792 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
793 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
794 if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
795 setf racc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
796 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
797 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
798 let n = n + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
799 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
800 setf yacc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
801 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
802 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
803 func dist#ft#Redif() |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
804 let lnum = 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
805 while lnum <= 5 && lnum < line('$') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
806 if getline(lnum) =~ "^\ctemplate-type:" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
807 setf redif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
808 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
809 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
810 let lnum = lnum + 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
811 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
812 endfunc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
813 |
26628
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
814 " This function is called for all files under */debian/patches/*, make sure not |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
815 " to non-dep3patch files, such as README and other text files. |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
816 func dist#ft#Dep3patch() |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
817 if expand('%:t') ==# 'series' |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
818 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
819 endif |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
820 |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
821 for ln in getline(1, 100) |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
822 if ln =~# '^\%(Description\|Subject\|Origin\|Bug\|Forwarded\|Author\|From\|Reviewed-by\|Acked-by\|Last-Updated\|Applied-Upstream\):' |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
823 setf dep3patch |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
824 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
825 elseif ln =~# '^---' |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
826 " end of headers found. stop processing |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
827 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
828 endif |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
829 endfor |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
830 endfunc |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
831 |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
832 " This function checks the first 15 lines for appearance of 'FoamFile' |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
833 " and then 'object' in a following line. |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
834 " In that case, it's probably an OpenFOAM file |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
835 func dist#ft#FTfoam() |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
836 let ffile = 0 |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
837 let lnum = 1 |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
838 while lnum <= 15 |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
839 if getline(lnum) =~# '^FoamFile' |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
840 let ffile = 1 |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
841 elseif ffile == 1 && getline(lnum) =~# '^\s*object' |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
842 setf foam |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
843 return |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
844 endif |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
845 let lnum = lnum + 1 |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
846 endwhile |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
847 endfunc |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
848 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
849 " Restore 'cpoptions' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
850 let &cpo = s:cpo_save |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
851 unlet s:cpo_save |