annotate runtime/autoload/dist/ft.vim @ 18379:0588431c7018

Added tag v8.1.2183 for changeset f2dac4c32f75d0e4fe050ca927fccfe2b3c36a26
author Bram Moolenaar <Bram@vim.org>
date Sat, 19 Oct 2019 19:00:04 +0200
parents bd7461db24b3
children d20ed2e5a776
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
16086
bd7461db24b3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16024
diff changeset
4 " Last Change: 2019 Mar 08
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
2b30a2b4bde2 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 14668
diff changeset
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
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 func dist#ft#EuphoriaCheck()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 if exists('g:filetype_euphoria')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 exe 'setf ' . g:filetype_euphoria
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 setf euphoria3
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
183 func dist#ft#DtraceCheck()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 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
185 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
186 " 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
187 setf d
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 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
189 setf dtrace
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
191 setf d
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
192 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
194
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 func dist#ft#FTe()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 if exists('g:filetype_euphoria')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 exe 'setf ' . g:filetype_euphoria
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
199 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
200 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
201 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 setf specman
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 setf eiffel
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 " 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
212 func dist#ft#FThtml()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
213 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
214 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
215 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
216 setf xhtml
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 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
220 setf htmldjango
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 endwhile
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
225 setf FALLBACK html
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
227
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
228 " 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
229 func dist#ft#FTidl()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 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
231 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
232 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
233 setf msidl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 setf idl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
241 " 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
242 func dist#ft#ProtoCheck(default)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
243 " 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
244 " 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
245 " 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
246 " 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
247 " chacter before the ';'.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
248 if getline(2) =~ '.;$'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
249 setf cpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 exe 'setf ' . a:default
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
253 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 func dist#ft#FTm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 let n = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 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
258 while n < 100
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
259 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
260 if line =~ '^\s*/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 " /* ... */ 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
262 " 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
263 " anything more definitive.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
264 let saw_comment = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 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
267 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
269 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 if line =~ '^\s*%'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271 setf matlab
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
273 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274 if line =~ '^\s*(\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
275 setf mma
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
276 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
277 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 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
279 setf murphi
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
284
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
285 if saw_comment
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
286 " 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
287 " 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
288 " common.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
289 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
290 elseif exists("g:filetype_m")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
291 " Use user specified default filetype for .m
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 exe "setf " . g:filetype_m
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 " Default is matlab
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 setf matlab
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
296 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 func dist#ft#FTmms()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
300 let n = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 while n < 10
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
303 if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 setf mmix
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
305 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
306 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307 if line =~ '^\s*#'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
308 setf make
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
309 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
312 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 setf mmix
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
316 " 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
317 " 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
318 func dist#ft#FTnroff()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 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
320 setf nroff
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 return 0
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
324 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
325
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
326 func dist#ft#FTmm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
327 let n = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 while n < 10
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 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
331 setf objcpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
333 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 setf nroff
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
339 func dist#ft#FTpl()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 if exists("g:filetype_pl")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 exe "setf " . g:filetype_pl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 " 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
344 " 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
345 let l = getline(nextnonblank(1))
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 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
347 setf prolog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 endif
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 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 func dist#ft#FTinc()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 if exists("g:filetype_inc")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 exe "setf " . g:filetype_inc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 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
359 if lines =~? "perlscript"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 setf aspperl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 elseif lines =~ "<%"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 setf aspvbs
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 elseif lines =~ "<?"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 setf php
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 call dist#ft#FTasmsyntax()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 if exists("b:asmsyntax")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 exe "setf " . fnameescape(b:asmsyntax)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 setf pov
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
375
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 func dist#ft#FTprogress_cweb()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 if exists("g:filetype_w")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 exe "setf " . g:filetype_w
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 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
382 setf progress
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 setf cweb
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 func dist#ft#FTprogress_asm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 if exists("g:filetype_i")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 exe "setf " . g:filetype_i
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 return
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 " 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
394 " If not found, assume Progress.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 while lnum <= 10 && lnum < line('$')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 let line = getline(lnum)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 if line =~ '^\s*;' || line =~ '^\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 call dist#ft#FTasm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 elseif line !~ '^\s*$' || line =~ '^/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 " 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
403 " 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
404 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 endw
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 setf progress
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
409 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
410
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
411 func dist#ft#FTprogress_pascal()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 if exists("g:filetype_p")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 exe "setf " . g:filetype_p
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 " 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
417 " 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
418 " If not found, assume Progress.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 while lnum <= 10 && lnum < line('$')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 let line = getline(lnum)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
422 if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
423 \ || line =~ '^\s*{' || line =~ '^\s*(\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 setf pascal
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 elseif line !~ '^\s*$' || line =~ '^/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 " 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
428 " 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
429 break
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 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 endw
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433 setf progress
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436 func dist#ft#FTr()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437 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
438
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 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
440 " 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
441 if getline(n) =~? '\<REBOL\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 setf rebol
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
443 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 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
448 " R has # comments
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 if getline(n) =~ '^\s*#'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450 setf r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 " Rexx has /* comments */
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454 if getline(n) =~ '^\s*/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
455 setf rexx
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 " 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
461 if exists("g:filetype_r")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 exe "setf " . g:filetype_r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
464 " 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
465 setf r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
466 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
467 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 func dist#ft#McSetf()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 " 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
471 " 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
472 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
473 let line = getline(lnum)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 if line =~ '^\s*\(#\|dnl\)'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 setf m4 " Sendmail .mc file
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 elseif line =~ '^\s*;'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 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
479 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
481 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 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
483 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 " 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
486 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
487 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
488 " 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
489 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
490 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
491 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
492 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
493 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 if a:name =~ '\<csh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495 " 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
496 call dist#ft#SetFileTypeShell("csh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498 elseif a:name =~ '\<tcsh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499 " 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
500 call dist#ft#SetFileTypeShell("tcsh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
501 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502 elseif a:name =~ '\<zsh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
503 " 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
504 call dist#ft#SetFileTypeShell("zsh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
505 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506 elseif a:name =~ '\<ksh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 let b:is_kornshell = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508 if exists("b:is_bash")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
509 unlet b:is_bash
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511 if exists("b:is_sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512 unlet b:is_sh
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
513 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
514 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
515 let b:is_bash = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 if exists("b:is_kornshell")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
517 unlet b:is_kornshell
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 if exists("b:is_sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520 unlet b:is_sh
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522 elseif a:name =~ '\<sh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 let b:is_sh = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
524 if exists("b:is_kornshell")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525 unlet b:is_kornshell
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 if exists("b:is_bash")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 unlet b:is_bash
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 call dist#ft#SetFileTypeShell("sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 " 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
535 " as used for Tcl.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 " 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
537 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
538 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
539 " 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
540 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
541 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 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
543 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 let l = 2
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 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
547 " Skip empty and comment lines.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
548 let l = l + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
549 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 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
551 " 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
552 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
553 if n =~ '\<tclsh\|\<wish'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554 setf tcl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
556 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
557 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558 exe "setf " . a:name
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
560
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
561 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
562 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
563 " 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
564 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
565 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
566 if exists("g:filetype_csh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567 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
568 elseif &shell =~ "tcsh"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 call dist#ft#SetFileTypeShell("tcsh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 call dist#ft#SetFileTypeShell("csh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
572 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 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
576 func dist#ft#FTRules()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 let path = expand('<amatch>:p')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 setf udevrules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
580 return
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 if path =~ '^/etc/ufw/'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 setf conf " Better than hog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 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
587 setf javascript
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588 return
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 try
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
591 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
592 catch /^Vim\%((\a\+)\)\=:E484/
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 setf hog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 endtry
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 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
597 for line in config_lines
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 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
599 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
600 if dir == udev_rules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 setf udevrules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
602 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 break
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 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 setf hog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 func dist#ft#SQL()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 if exists("g:filetype_sql")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 exe "setf " . g:filetype_sql
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613 setf sql
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
614 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
616
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617 " 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
618 " 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
619 " 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
620 " file.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 " (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
622 " a Perl file.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
623 func dist#ft#FTperl()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624 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
625 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
626 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
627 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
629 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
630 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 endif
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
633 let save_cursor = getpos('.')
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
634 call cursor(1,1)
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
635 let has_use = search('^use\s\s*\k', 'c', 30)
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
636 call setpos('.', save_cursor)
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
637 if has_use
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
639 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
640 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
641 return 0
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
643
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
644 " 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
645 " 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
646 " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 13051
diff changeset
647 " 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
648 func dist#ft#FTtex()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 let firstline = getline(1)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650 if firstline =~ '^%&\s*\a\+'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651 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
652 let format = substitute(format, 'pdf', '', '')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
653 if format == 'tex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
654 let format = 'latex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655 elseif format == 'plaintex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 let format = 'plain'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
657 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
658 elseif expand('%') =~ 'tex/context/.*/.*.tex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 let format = 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 " 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
662 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
663 " 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
664 let save_cursor = getpos('.')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 call cursor(1,1)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 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
667 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
668 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
669 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
670 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
671 \ 'cnp', firstNC + 1000)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672 if kwline == 1 " lpat matched
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 let format = 'latex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674 elseif kwline == 2 " cpat matched
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
675 let format = 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
676 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
677 " 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
678 " 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
679 " if cline > 0
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 " let format = 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681 " endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 " 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
683 " let format = 'tex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684 " endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685 endif " firstNC
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686 call setpos('.', save_cursor)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 endif " firstline =~ '^%&\s*\a\+'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 " 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
690 if format == 'plain'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 setf plaintex
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692 elseif format == 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 setf context
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
694 else " probably LaTeX
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
695 setf tex
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
696 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 func dist#ft#FTxml()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
701 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
702 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
703 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 " DocBook 4 or DocBook 5.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 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
706 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
707 if is_docbook4 || is_docbook5
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 let b:docbk_type = "xml"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709 if is_docbook5
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 let b:docbk_ver = 5
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
712 let b:docbk_ver = 4
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
713 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 setf docbk
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
715 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
716 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
717 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
718 setf xbl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
721 let n += 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
722 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
723 setf xml
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
724 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
725
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 func dist#ft#FTy()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727 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
728 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
729 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
730 if line =~ '^\s*%'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 setf yacc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
733 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
734 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
735 setf racc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
738 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 setf yacc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
743 func dist#ft#Redif()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
744 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
745 while lnum <= 5 && lnum < line('$')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
746 if getline(lnum) =~ "^\ctemplate-type:"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 setf redif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
753
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
754
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 " Restore 'cpoptions'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 let &cpo = s:cpo_save
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 unlet s:cpo_save