annotate runtime/autoload/dist/ft.vim @ 27420:978890380129 v8.2.4238

patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform" Commit: https://github.com/vim/vim/commit/bd8168c7705e315827642f2976ec59e26b7fe009 Author: =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com> Date: Fri Jan 28 14:15:09 2022 +0000 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform" Problem: *.tf file could be fileytpe "tf" or "terraform". Solution: Detect the type from the file contents. (closes https://github.com/vim/vim/issues/9642)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Jan 2022 15:30:03 +0100
parents 9f72ec92d361
children 5825405e4e2c
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>
27162
b19230a8d40a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 27070
diff changeset
4 " Last Change: 2022 Jan 11
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " These functions are moved here from runtime/filetype.vim to make startup
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " faster.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " Line continuation is used here, remove 'C' from 'cpoptions'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 let s:cpo_save = &cpo
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 set cpo&vim
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 func dist#ft#Check_inp()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 if getline(1) =~ '^\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 setf abaqus
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 let n = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 if line("$") > 500
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 let nmax = 500
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 let nmax = line("$")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 while n <= nmax
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 if getline(n) =~? "^header surface data"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 setf trasys
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 " This function checks for the kind of assembly that is wanted by the user, or
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 " can be detected from the first five lines of the file.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 func dist#ft#FTasm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " make sure b:asmsyntax exists
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 if !exists("b:asmsyntax")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 let b:asmsyntax = ""
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 if b:asmsyntax == ""
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 call dist#ft#FTasmsyntax()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " if b:asmsyntax still isn't set, default to asmsyntax or GNU
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 if b:asmsyntax == ""
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 if exists("g:asmsyntax")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 let b:asmsyntax = g:asmsyntax
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 let b:asmsyntax = "asm"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 exe "setf " . fnameescape(b:asmsyntax)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 func dist#ft#FTasmsyntax()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 " see if file contains any asmsyntax=foo overrides. If so, change
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 " b:asmsyntax appropriately
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 \" ".getline(5)." "
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 if match != ''
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 let b:asmsyntax = match
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 let b:asmsyntax = "vmasm"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69
27287
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
70 func dist#ft#FTbas()
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
71 if exists("g:filetype_bas")
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
72 exe "setf " . g:filetype_bas
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
73 return
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
74 endif
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
75
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
76 " most frequent FreeBASIC-specific keywords in distro files
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
77 let fb_keywords = '\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!'
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
78 let fb_preproc = '\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)'
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
79 let fb_comment = "^\\s*/'"
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
80 " OPTION EXPLICIT, without the leading underscore, is common to many dialects
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
81 let qb64_preproc = '\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)'
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
82
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
83 let lines = getline(1, min([line("$"), 100]))
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
84
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
85 if match(lines, fb_preproc) > -1 || match(lines, fb_comment) > -1 || match(lines, fb_keywords) > -1
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
86 setf freebasic
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
87 elseif match(lines, qb64_preproc) > -1
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
88 setf qb64
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
89 elseif match(lines, '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)') > -1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 setf vb
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 else
27287
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
92 setf basic
12816
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#FTbtm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 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
98 setf dosbatch
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 setf btm
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 func dist#ft#BindzoneCheck(default)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 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
106 setf bindzone
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 elseif a:default != ''
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108 exe 'setf ' . a:default
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112 func dist#ft#FTlpc()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 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
114 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
115 while lnum <= 12
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
116 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
117 setf lpc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
118 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
119 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
120 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
121 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
122 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
123 setf c
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 func dist#ft#FTheader()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
127 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
128 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
129 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
131 setf objcpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 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
134 setf c
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 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
136 setf ch
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
137 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 setf cpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
139 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
140 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
141
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142 " 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
143 " 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
144 " 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
145 " 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
146 " Otherwise CHILL is assumed.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 func dist#ft#FTchange()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 while lnum <= 10
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 if getline(lnum)[0] == '@'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
151 setf change
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
153 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 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
155 setf ch
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
157 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158 if getline(lnum) =~ "MODULE"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
159 setf chill
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
160 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
161 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
162 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
163 setf ch
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 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 setf chill
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 func dist#ft#FTent()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
172 " 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
173 " 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
174 " If not found, assume SGML.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 while lnum < 6
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 let line = getline(lnum)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 if line =~ '^\s*[#{]'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 setf cl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
180 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 elseif line !~ '^\s*$'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 " 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
183 " 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
184 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
186 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187 endw
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
188 setf dtd
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
189 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
190
25026
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
191 func dist#ft#ExCheck()
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
192 let lines = getline(1, min([line("$"), 100]))
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
193 if exists('g:filetype_euphoria')
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
194 exe 'setf ' . g:filetype_euphoria
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
195 elseif match(lines, '^--\|^ifdef\>\|^include\>') > -1
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
196 setf euphoria3
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
197 else
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
198 setf elixir
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
199 endif
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
200 endfunc
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
201
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 func dist#ft#EuphoriaCheck()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
203 if exists('g:filetype_euphoria')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
204 exe 'setf ' . g:filetype_euphoria
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
206 setf euphoria3
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
208 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
209
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
210 func dist#ft#DtraceCheck()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
211 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
212 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
213 " 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
214 setf d
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
215 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
216 setf dtrace
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
217 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
218 setf d
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
219 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
221
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 func dist#ft#FTe()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 if exists('g:filetype_euphoria')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 exe 'setf ' . g:filetype_euphoria
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
225 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226 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
227 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
228 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
229 setf specman
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
230 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
231 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
232 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
234 setf eiffel
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 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
237
26311
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
238 " Distinguish between Forth and F#.
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
239 " Provided by Doug Kearns.
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
240 func dist#ft#FTfs()
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
241 if exists("g:filetype_fs")
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
242 exe "setf " . g:filetype_fs
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
243 else
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
244 let line = getline(nextnonblank(1))
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
245 " comments and colon definitions
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
246 if line =~ '^\s*\.\=( ' || line =~ '^\s*\\G\= ' || line =~ '^\\$'
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
247 \ || line =~ '^\s*: \S'
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
248 setf forth
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
249 else
26344
36f3a77e4b8c patch 8.2.3703: most people call F# "fsharp" and not "fs"
Bram Moolenaar <Bram@vim.org>
parents: 26311
diff changeset
250 setf fsharp
26311
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
251 endif
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
252 endif
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
253 endfunc
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
254
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 " 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
256 func dist#ft#FThtml()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
257 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
258 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
259 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
260 setf xhtml
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
261 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
262 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
263 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
264 setf htmldjango
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
265 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
266 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
267 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
268 endwhile
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
269 setf FALLBACK html
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
270 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
271
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
272 " 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
273 func dist#ft#FTidl()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
274 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
275 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
276 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
277 setf msidl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
278 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
279 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
280 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
281 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
282 setf idl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
283 endfunc
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 " 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
286 func dist#ft#ProtoCheck(default)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
287 " 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
288 " 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
289 " 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
290 " 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
291 " chacter before the ';'.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
292 if getline(2) =~ '.;$'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
293 setf cpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
294 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
295 exe 'setf ' . a:default
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#FTm()
25727
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
300 if exists("g:filetype_m")
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
301 exe "setf " . g:filetype_m
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
302 return
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
303 endif
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
304
25794
374adc90efa5 patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 25727
diff changeset
305 " excluding end(for|function|if|switch|while) common to Murphi
374adc90efa5 patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 25727
diff changeset
306 let octave_block_terminators = '\<end\%(_try_catch\|classdef\|enumeration\|events\|methods\|parfor\|properties\)\>'
25727
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
307
26296
9f32ccdadd22 patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents: 25794
diff changeset
308 let objc_preprocessor = '^\s*#\s*\%(import\|include\|define\|if\|ifn\=def\|undef\|line\|error\|pragma\)\>'
9f32ccdadd22 patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents: 25794
diff changeset
309
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
310 let n = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
311 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
312 while n < 100
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
313 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 if line =~ '^\s*/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 " /* ... */ 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
316 " 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
317 " anything more definitive.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 let saw_comment = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
319 endif
26296
9f32ccdadd22 patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents: 25794
diff changeset
320 if line =~ '^\s*//' || line =~ '^\s*@import\>' || line =~ objc_preprocessor
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
321 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
322 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
323 endif
25794
374adc90efa5 patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 25727
diff changeset
324 if line =~ '^\s*\%(#\|%!\)' || line =~ '^\s*unwind_protect\>' ||
25727
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
325 \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
326 setf octave
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
327 return
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
328 endif
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
329 " TODO: could be Matlab or Octave
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 if line =~ '^\s*%'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
331 setf matlab
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 if line =~ '^\s*(\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
335 setf mma
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
336 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
337 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
338 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
339 setf murphi
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
340 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
341 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
342 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
343 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
344
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
345 if saw_comment
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
346 " 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
347 " 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
348 " common.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
349 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 else
25727
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
351 " Default is Matlab
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
352 setf matlab
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
353 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
354 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
356 func dist#ft#FTmms()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
357 let n = 1
19039
d20ed2e5a776 Update a few runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
358 while n < 20
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
360 if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
361 setf mmix
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
362 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
363 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
364 if line =~ '^\s*#'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
365 setf make
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
366 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 setf mmix
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 " 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
374 " 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
375 func dist#ft#FTnroff()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 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
377 setf nroff
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
378 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380 return 0
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
382
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
383 func dist#ft#FTmm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
384 let n = 1
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19039
diff changeset
385 while n < 20
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
387 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
388 setf objcpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
390 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
392 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
393 setf nroff
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
394 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
395
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 func dist#ft#FTpl()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 if exists("g:filetype_pl")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 exe "setf " . g:filetype_pl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 " 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
401 " 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
402 let l = getline(nextnonblank(1))
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 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
404 setf prolog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
407 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408 endif
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#FTinc()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
412 if exists("g:filetype_inc")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
413 exe "setf " . g:filetype_inc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 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
416 if lines =~? "perlscript"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 setf aspperl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
418 elseif lines =~ "<%"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419 setf aspvbs
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
420 elseif lines =~ "<?"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
421 setf php
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
422 " Pascal supports // comments but they're vary rarely used for file
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
423 " headers so assume POV-Ray
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
424 elseif lines =~ '^\s*\%({\|(\*\)' || lines =~? s:ft_pascal_keywords
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
425 setf pascal
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
427 call dist#ft#FTasmsyntax()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 if exists("b:asmsyntax")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 exe "setf " . fnameescape(b:asmsyntax)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
430 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431 setf pov
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
432 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
433 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
434 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
435 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
436
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
437 func dist#ft#FTprogress_cweb()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
438 if exists("g:filetype_w")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
439 exe "setf " . g:filetype_w
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
440 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
441 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
442 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
443 setf progress
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
444 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
445 setf cweb
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
446 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
447 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
448
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
449 func dist#ft#FTprogress_asm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
450 if exists("g:filetype_i")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
451 exe "setf " . g:filetype_i
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
452 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
453 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
454 " 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
455 " If not found, assume Progress.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
456 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
457 while lnum <= 10 && lnum < line('$')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
458 let line = getline(lnum)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
459 if line =~ '^\s*;' || line =~ '^\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
460 call dist#ft#FTasm()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
461 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
462 elseif line !~ '^\s*$' || line =~ '^/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 " 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
464 " 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
465 break
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 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
468 endw
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 setf progress
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
470 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
472 let s:ft_pascal_comments = '^\s*\%({\|(\*\|//\)'
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
473 let s:ft_pascal_keywords = '^\s*\%(program\|unit\|library\|uses\|begin\|procedure\|function\|const\|type\|var\)\>'
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
474
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
475 func dist#ft#FTprogress_pascal()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476 if exists("g:filetype_p")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
477 exe "setf " . g:filetype_p
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
479 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 " 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
481 " 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
482 " If not found, assume Progress.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 while lnum <= 10 && lnum < line('$')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 let line = getline(lnum)
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
486 if line =~ s:ft_pascal_comments || line =~? s:ft_pascal_keywords
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 setf pascal
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
488 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
489 elseif line !~ '^\s*$' || line =~ '^/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
490 " 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
491 " 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
492 break
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 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
495 endw
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496 setf progress
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
499 func dist#ft#FTpp()
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
500 if exists("g:filetype_pp")
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
501 exe "setf " . g:filetype_pp
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
502 else
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
503 let line = getline(nextnonblank(1))
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
504 if line =~ s:ft_pascal_comments || line =~? s:ft_pascal_keywords
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
505 setf pascal
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
506 else
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
507 setf puppet
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
508 endif
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
509 endif
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
510 endfunc
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
511
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512 func dist#ft#FTr()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
513 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
514
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
515 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
516 " 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
517 if getline(n) =~? '\<REBOL\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 setf rebol
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
520 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
521 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
522
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 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
524 " R has # comments
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525 if getline(n) =~ '^\s*#'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
526 setf r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
527 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
528 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
529 " Rexx has /* comments */
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
530 if getline(n) =~ '^\s*/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 setf rexx
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
533 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
534 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
536 " 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
537 if exists("g:filetype_r")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
538 exe "setf " . g:filetype_r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
539 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
540 " 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
541 setf r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
543 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 func dist#ft#McSetf()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
546 " 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
547 " 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
548 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
549 let line = getline(lnum)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 if line =~ '^\s*\(#\|dnl\)'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
551 setf m4 " Sendmail .mc file
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
552 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 elseif line =~ '^\s*;'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554 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
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 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558 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
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 " 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
562 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
563 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
564 " 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
565 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
566 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
567 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
568 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
569 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
570 if a:name =~ '\<csh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
571 " 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
572 call dist#ft#SetFileTypeShell("csh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
573 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
574 elseif a:name =~ '\<tcsh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
575 " 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
576 call dist#ft#SetFileTypeShell("tcsh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
577 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
578 elseif a:name =~ '\<zsh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
579 " 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
580 call dist#ft#SetFileTypeShell("zsh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
581 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
582 elseif a:name =~ '\<ksh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
583 let b:is_kornshell = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
584 if exists("b:is_bash")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
585 unlet b:is_bash
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
586 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
587 if exists("b:is_sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
588 unlet b:is_sh
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 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
591 let b:is_bash = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592 if exists("b:is_kornshell")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 unlet b:is_kornshell
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
594 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 if exists("b:is_sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 unlet b:is_sh
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 elseif a:name =~ '\<sh\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599 let b:is_sh = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
600 if exists("b:is_kornshell")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 unlet b:is_kornshell
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 if exists("b:is_bash")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 unlet b:is_bash
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
607 call dist#ft#SetFileTypeShell("sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 " 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
611 " as used for Tcl.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 " 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
613 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
614 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
615 " 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
616 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
617 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
618 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
619 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
621 let l = 2
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622 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
623 " Skip empty and comment lines.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
624 let l = l + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
625 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 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
627 " 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
628 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
629 if n =~ '\<tclsh\|\<wish'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 setf tcl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
632 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634 exe "setf " . a:name
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
636
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
637 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
638 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
639 " 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
640 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
641 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
642 if exists("g:filetype_csh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
643 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
644 elseif &shell =~ "tcsh"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645 call dist#ft#SetFileTypeShell("tcsh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
646 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 call dist#ft#SetFileTypeShell("csh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
648 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
649 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
650
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651 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
652 func dist#ft#FTRules()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
653 let path = expand('<amatch>:p')
21853
aab3fe874b05 patch 8.2.1476: filetype test fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 21849
diff changeset
654 if path =~ '/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|\%(usr/\)\=lib/udev/\%(rules\.d/\)\=.*\.rules\)$'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655 setf udevrules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
656 return
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 if path =~ '^/etc/ufw/'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 setf conf " Better than hog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
660 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
661 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662 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
663 setf javascript
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 try
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 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
668 catch /^Vim\%((\a\+)\)\=:E484/
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
669 setf hog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671 endtry
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672 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
673 for line in config_lines
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674 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
675 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
676 if dir == udev_rules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
677 setf udevrules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
680 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
681 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 setf hog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
685 func dist#ft#SQL()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
686 if exists("g:filetype_sql")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687 exe "setf " . g:filetype_sql
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
688 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
689 setf sql
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
690 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
691 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
692
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
693 " 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
694 " 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
695 " 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
696 " file.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
697 " (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
698 " a Perl file.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
699 func dist#ft#FTperl()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 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
701 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
702 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
705 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
706 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 endif
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
709 let save_cursor = getpos('.')
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
710 call cursor(1,1)
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
711 let has_use = search('^use\s\s*\k', 'c', 30)
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
712 call setpos('.', save_cursor)
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
713 if has_use
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
715 return 1
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 return 0
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
718 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
719
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 " 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
721 " 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
722 " 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
723 " 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
724 func dist#ft#FTtex()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
725 let firstline = getline(1)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 if firstline =~ '^%&\s*\a\+'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
727 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
728 let format = substitute(format, 'pdf', '', '')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
729 if format == 'tex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
730 let format = 'latex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
731 elseif format == 'plaintex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
732 let format = 'plain'
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 elseif expand('%') =~ 'tex/context/.*/.*.tex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
735 let format = 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
737 " 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
738 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
739 " 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
740 let save_cursor = getpos('.')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
741 call cursor(1,1)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742 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
743 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
744 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
745 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
746 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
747 \ 'cnp', firstNC + 1000)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 if kwline == 1 " lpat matched
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 let format = 'latex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750 elseif kwline == 2 " cpat matched
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
751 let format = 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 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
753 " 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
754 " 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
755 " if cline > 0
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 " let format = 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
757 " endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
758 " 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
759 " let format = 'tex'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 " endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 endif " firstNC
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
762 call setpos('.', save_cursor)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763 endif " firstline =~ '^%&\s*\a\+'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
764
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 " 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
766 if format == 'plain'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 setf plaintex
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 elseif format == 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769 setf context
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
770 else " probably LaTeX
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
771 setf tex
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
772 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
773 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
774 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
775
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
776 func dist#ft#FTxml()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
777 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
778 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
779 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780 " DocBook 4 or DocBook 5.
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
781 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
782 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
783 if is_docbook4 || is_docbook5
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784 let b:docbk_type = "xml"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
785 if is_docbook5
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
786 let b:docbk_ver = 5
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
788 let b:docbk_ver = 4
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
789 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
790 setf docbk
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
791 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
792 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793 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
794 setf xbl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
797 let n += 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
799 setf xml
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
800 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
801
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
802 func dist#ft#FTy()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
803 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
804 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
805 let line = getline(n)
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
806 if line =~ '^\s*%'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
807 setf yacc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
808 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
809 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
810 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
811 setf racc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
812 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
813 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 let n = n + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
815 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
816 setf yacc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
818
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819 func dist#ft#Redif()
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
820 let lnum = 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 while lnum <= 5 && lnum < line('$')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 if getline(lnum) =~ "^\ctemplate-type:"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
823 setf redif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
825 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
826 let lnum = lnum + 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
827 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
828 endfunc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
829
26628
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
830 " This function is called for all files under */debian/patches/*, make sure not
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
831 " to non-dep3patch files, such as README and other text files.
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
832 func dist#ft#Dep3patch()
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
833 if expand('%:t') ==# 'series'
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
834 return
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
835 endif
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
836
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
837 for ln in getline(1, 100)
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
838 if ln =~# '^\%(Description\|Subject\|Origin\|Bug\|Forwarded\|Author\|From\|Reviewed-by\|Acked-by\|Last-Updated\|Applied-Upstream\):'
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
839 setf dep3patch
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
840 return
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
841 elseif ln =~# '^---'
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
842 " end of headers found. stop processing
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
843 return
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
844 endif
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
845 endfor
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
846 endfunc
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
847
27070
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
848 " This function checks the first 15 lines for appearance of 'FoamFile'
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
849 " and then 'object' in a following line.
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
850 " In that case, it's probably an OpenFOAM file
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
851 func dist#ft#FTfoam()
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
852 let ffile = 0
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
853 let lnum = 1
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
854 while lnum <= 15
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
855 if getline(lnum) =~# '^FoamFile'
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
856 let ffile = 1
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
857 elseif ffile == 1 && getline(lnum) =~# '^\s*object'
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
858 setf foam
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
859 return
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
860 endif
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
861 let lnum = lnum + 1
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
862 endwhile
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
863 endfunc
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
864
27420
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
865 " Determine if a *.tf file is TF mud client or terraform
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
866 func dist#ft#FTtf()
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
867 let numberOfLines = line('$')
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
868 for i in range(1, numberOfLines)
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
869 let currentLine = trim(getline(i))
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
870 let firstCharacter = currentLine[0]
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
871 if firstCharacter !=? ";" && firstCharacter !=? "/" && firstCharacter !=? ""
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
872 setf terraform
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
873 return
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
874 endif
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
875 endfor
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
876 setf tf
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
877 endfunc
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
878
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
879
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880 " Restore 'cpoptions'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881 let &cpo = s:cpo_save
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 unlet s:cpo_save