annotate runtime/autoload/dist/ft.vim @ 28390:cc4d3ded4004 v8.2.4720

patch 8.2.0003: Build file dependencies are incomplete Commit: https://github.com/vim/vim/commit/0bbf09ca41382302493e5db51b01d2fbdc778586 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 9 15:16:53 2022 +0100 patch 8.2.0003: Build file dependencies are incomplete Problem: Build file dependencies are incomplete. Solution: Fix the dependencies. (Ken Takata, closes https://github.com/vim/vim/issues/5356)
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 Apr 2022 16:30:03 +0200
parents 6dd88e45d47d
children 5896c0f6cdd7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
1 vim9script
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
3 # Vim functions for file type detection
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
4 #
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
5 # Maintainer: Bram Moolenaar <Bram@vim.org>
28379
6dd88e45d47d Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 28351
diff changeset
6 # Last Change: 2022 Apr 06
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
8 # These functions are moved here from runtime/filetype.vim to make startup
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
9 # faster.
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
11 export def Check_inp()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 if getline(1) =~ '^\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 setf abaqus
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
15 var n = 1
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
16 var nmax = line("$") > 500 ? 500 : line("$")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 while n <= nmax
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 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
19 setf trasys
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
22 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
25 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
27 # This function checks for the kind of assembly that is wanted by the user, or
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
28 # can be detected from the first five lines of the file.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
29 export def FTasm()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
30 # make sure b:asmsyntax exists
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 if !exists("b:asmsyntax")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
32 b:asmsyntax = ""
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 if b:asmsyntax == ""
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
36 FTasmsyntax()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
39 # if b:asmsyntax still isn't set, default to asmsyntax or GNU
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 if b:asmsyntax == ""
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 if exists("g:asmsyntax")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
42 b:asmsyntax = g:asmsyntax
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
44 b:asmsyntax = "asm"
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
48 exe "setf " .. fnameescape(b:asmsyntax)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
49 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
51 export def FTasmsyntax()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
52 # see if the file contains any asmsyntax=foo overrides. If so, change
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
53 # b:asmsyntax appropriately
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
54 var head = " " .. getline(1) .. " " .. getline(2) .. " "
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
55 .. getline(3) .. " " .. getline(4) .. " " .. getline(5) .. " "
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
56 var match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 if match != ''
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
58 b:asmsyntax = match
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
60 b:asmsyntax = "vmasm"
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
62 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
64 var ft_visual_basic_content = '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
27493
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
65
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
66 # See FTfrm() for Visual Basic form file detection
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
67 export def FTbas()
27287
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
68 if exists("g:filetype_bas")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
69 exe "setf " .. g:filetype_bas
27287
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
70 return
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
71 endif
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
72
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
73 # most frequent FreeBASIC-specific keywords in distro files
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
74 var fb_keywords = '\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
75 var fb_preproc = '\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
76 var fb_comment = "^\\s*/'"
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
77 # OPTION EXPLICIT, without the leading underscore, is common to many dialects
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
78 var qb64_preproc = '\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)'
27287
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
79
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
80 var lines = getline(1, min([line("$"), 100]))
27287
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
81
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
82 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
83 setf freebasic
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
84 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
85 setf qb64
27845
e63514ae0c29 patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents: 27557
diff changeset
86 elseif match(lines, ft_visual_basic_content) > -1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 setf vb
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 else
27287
9f72ec92d361 patch 8.2.4172: filetype detection for BASIC is not optimal
Bram Moolenaar <Bram@vim.org>
parents: 27162
diff changeset
89 setf basic
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
91 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
93 export def FTbtm()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 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
95 setf dosbatch
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 setf btm
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
99 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
101 export def BindzoneCheck(default = '')
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
102 if getline(1) .. getline(2) .. getline(3) .. getline(4)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
103 =~ '^; <<>> DiG [0-9.]\+.* <<>>\|$ORIGIN\|$TTL\|IN\s\+SOA'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 setf bindzone
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
105 elseif default != ''
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
106 exe 'setf ' .. default
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
108 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109
28390
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
110 # Returns true if file content looks like RAPID
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
111 def IsRapid(sChkExt: string = ""): bool
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
112 if sChkExt == "cfg"
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
113 return getline(1) =~? '\v^%(EIO|MMC|MOC|PROC|SIO|SYS):CFG'
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
114 endif
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
115 # called from FTmod, FTprg or FTsys
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
116 return getline(nextnonblank(1)) =~? '\v^\s*%(\%{3}|module\s+\k+\s*%(\(|$))'
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
117 enddef
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
118
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
119 export def FTcfg()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
120 if exists("g:filetype_cfg")
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
121 exe "setf " .. g:filetype_cfg
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
122 elseif IsRapid("cfg")
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
123 setf rapid
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
124 else
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
125 setf cfg
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
126 endif
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
127 enddef
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
128
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
129 export def FTlpc()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
130 if exists("g:lpc_syntax_for_c")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
131 var lnum = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
132 while lnum <= 12
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
133 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
134 setf lpc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
135 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
136 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
137 lnum += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
138 endwhile
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 setf c
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
141 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
142
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
143 export def FTheader()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
144 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
145 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
146 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
147 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
148 setf objcpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
149 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
150 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
151 setf c
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
152 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
153 setf ch
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
154 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
155 setf cpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
156 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
157 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
158
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
159 # This function checks if one of the first ten lines start with a '@'. In
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
160 # that case it is probably a change file.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
161 # If the first line starts with # or ! it's probably a ch file.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
162 # If a line has "main", "include", "//" or "/*" it's probably ch.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
163 # Otherwise CHILL is assumed.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
164 export def FTchange()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
165 var lnum = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
166 while lnum <= 10
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
167 if getline(lnum)[0] == '@'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
168 setf change
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
169 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
170 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
171 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
172 setf ch
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
173 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
174 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
175 if getline(lnum) =~ "MODULE"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
176 setf chill
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
177 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
178 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
179 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
180 setf ch
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
181 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
182 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
183 lnum += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
184 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
185 setf chill
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
186 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
187
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
188 export def FTent()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
189 # This function checks for valid cl syntax in the first five lines.
28390
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
190 # Look for either an opening comment, '#', or a block start, '{'.
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
191 # If not found, assume SGML.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
192 var lnum = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
193 while lnum < 6
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
194 var line = getline(lnum)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
195 if line =~ '^\s*[#{]'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
196 setf cl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
197 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
198 elseif line !~ '^\s*$'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
199 # Not a blank line, not a comment, and not a block start,
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
200 # so doesn't look like valid cl code.
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
201 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
202 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
203 lnum += 1
27972
9c0b7953016e patch 8.2.4511: filetype test fails
Bram Moolenaar <Bram@vim.org>
parents: 27903
diff changeset
204 endwhile
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
205 setf dtd
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
206 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
207
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
208 export def ExCheck()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
209 var lines = getline(1, min([line("$"), 100]))
25026
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
210 if exists('g:filetype_euphoria')
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
211 exe 'setf ' .. g:filetype_euphoria
25026
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
212 elseif match(lines, '^--\|^ifdef\>\|^include\>') > -1
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
213 setf euphoria3
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
214 else
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
215 setf elixir
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
216 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
217 enddef
25026
fda44c0b4b7b patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents: 23584
diff changeset
218
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
219 export def EuphoriaCheck()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
220 if exists('g:filetype_euphoria')
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
221 exe 'setf ' .. g:filetype_euphoria
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
222 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
223 setf euphoria3
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
224 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
225 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
226
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
227 export def DtraceCheck()
27877
834d3fba1e7c patch 8.2.4464: Dtrace files are recognized as filetype D
Bram Moolenaar <Bram@vim.org>
parents: 27845
diff changeset
228 if did_filetype()
834d3fba1e7c patch 8.2.4464: Dtrace files are recognized as filetype D
Bram Moolenaar <Bram@vim.org>
parents: 27845
diff changeset
229 # Filetype was already detected
834d3fba1e7c patch 8.2.4464: Dtrace files are recognized as filetype D
Bram Moolenaar <Bram@vim.org>
parents: 27845
diff changeset
230 return
834d3fba1e7c patch 8.2.4464: Dtrace files are recognized as filetype D
Bram Moolenaar <Bram@vim.org>
parents: 27845
diff changeset
231 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
232 var lines = getline(1, min([line("$"), 100]))
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
233 if match(lines, '^module\>\|^import\>') > -1
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
234 # D files often start with a module and/or import statement.
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
235 setf d
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
236 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
237 setf dtrace
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
238 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
239 setf d
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
240 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
241 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
242
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
243 export def FTe()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
244 if exists('g:filetype_euphoria')
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
245 exe 'setf ' .. g:filetype_euphoria
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
246 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
247 var n = 1
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
248 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
249 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
250 setf specman
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
251 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
252 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
253 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
254 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
255 setf eiffel
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
256 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
257 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
258
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
259 export def FTfrm()
27493
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
260 if exists("g:filetype_frm")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
261 exe "setf " .. g:filetype_frm
27493
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
262 return
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
263 endif
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
264
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
265 var lines = getline(1, min([line("$"), 5]))
27493
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
266
27845
e63514ae0c29 patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents: 27557
diff changeset
267 if match(lines, ft_visual_basic_content) > -1
27493
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
268 setf vb
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
269 else
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
270 setf form
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
271 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
272 enddef
27493
3af3dee7e5d9 patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 27492
diff changeset
273
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
274 # Distinguish between Forth and F#.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
275 # Provided by Doug Kearns.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
276 export def FTfs()
26311
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
277 if exists("g:filetype_fs")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
278 exe "setf " .. g:filetype_fs
26311
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
279 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
280 var line = getline(nextnonblank(1))
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
281 # comments and colon definitions
26311
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
282 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
283 \ || 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
284 setf forth
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
285 else
26344
36f3a77e4b8c patch 8.2.3703: most people call F# "fsharp" and not "fs"
Bram Moolenaar <Bram@vim.org>
parents: 26311
diff changeset
286 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
287 endif
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
288 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
289 enddef
26311
ce3678583211 patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents: 26296
diff changeset
290
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
291 # Distinguish between HTML, XHTML and Django
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
292 export def FThtml()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
293 var n = 1
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
294 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
295 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
296 setf xhtml
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
297 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
298 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
299 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
300 setf htmldjango
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
301 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
302 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
303 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
304 endwhile
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
305 setf FALLBACK html
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
306 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
307
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
308 # Distinguish between standard IDL and MS-IDL
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
309 export def FTidl()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
310 var n = 1
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
311 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
312 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
313 setf msidl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
314 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
315 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
316 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
317 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
318 setf idl
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
319 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
320
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
321 # Distinguish between "default" and Cproto prototype file. */
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
322 export def ProtoCheck(default: string)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
323 # Cproto files have a comment in the first line and a function prototype in
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
324 # the second line, it always ends in ";". Indent files may also have
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
325 # comments, thus we can't match comments to see the difference.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
326 # IDL files can have a single ';' in the second line, require at least one
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
327 # chacter before the ';'.
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
328 if getline(2) =~ '.;$'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
329 setf cpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
330 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
331 exe 'setf ' .. default
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
332 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
333 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
334
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
335 export def FTm()
25727
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
336 if exists("g:filetype_m")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
337 exe "setf " .. g:filetype_m
25727
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
338 return
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
339 endif
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
340
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
341 # excluding end(for|function|if|switch|while) common to Murphi
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
342 var 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
343
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
344 var objc_preprocessor = '^\s*#\s*\%(import\|include\|define\|if\|ifn\=def\|undef\|line\|error\|pragma\)\>'
26296
9f32ccdadd22 patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents: 25794
diff changeset
345
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
346 var n = 1
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
347 var saw_comment = 0 # Whether we've seen a multiline comment leader.
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
348 while n < 100
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
349 var line = getline(n)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
350 if line =~ '^\s*/\*'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
351 # /* ... */ is a comment in Objective C and Murphi, so we can't conclude
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
352 # it's either of them yet, but track this as a hint in case we don't see
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
353 # anything more definitive.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
354 saw_comment = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
355 endif
26296
9f32ccdadd22 patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents: 25794
diff changeset
356 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
357 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
358 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
359 endif
25794
374adc90efa5 patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents: 25727
diff changeset
360 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
361 \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
362 setf octave
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
363 return
71d3ebfb00b6 patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 25026
diff changeset
364 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
365 # 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
366 if line =~ '^\s*%'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
367 setf matlab
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
368 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
369 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
370 if line =~ '^\s*(\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
371 setf mma
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
372 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
373 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
374 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
375 setf murphi
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
376 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
377 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
378 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
379 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
380
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
381 if saw_comment
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
382 # We didn't see anything definitive, but this looks like either Objective C
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
383 # or Murphi based on the comment leader. Assume the former as it is more
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
384 # common.
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
385 setf objc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
386 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
387 # Default is Matlab
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
388 setf matlab
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
389 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
390 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
391
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
392 export def FTmms()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
393 var n = 1
19039
d20ed2e5a776 Update a few runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 16086
diff changeset
394 while n < 20
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
395 var line = getline(n)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
396 if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
397 setf mmix
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
398 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
399 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
400 if line =~ '^\s*#'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
401 setf make
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
402 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
403 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
404 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
405 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
406 setf mmix
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
407 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
408
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
409 # This function checks if one of the first five lines start with a dot. In
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
410 # that case it is probably an nroff file: 'filetype' is set and 1 is returned.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
411 export def FTnroff(): number
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
412 if getline(1)[0] .. getline(2)[0] .. getline(3)[0]
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
413 .. getline(4)[0] .. getline(5)[0] =~ '\.'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
414 setf nroff
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
415 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
416 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
417 return 0
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
418 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
419
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
420 export def FTmm()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
421 var n = 1
19968
1908e92b02fd Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 19039
diff changeset
422 while n < 20
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
423 if getline(n) =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
424 setf objcpp
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
425 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
426 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
427 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
428 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
429 setf nroff
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
430 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
431
28390
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
432 # Returns true if file content looks like LambdaProlog
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
433 def IsLProlog(): bool
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
434 # skip apparent comments and blank lines, what looks like
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
435 # LambdaProlog comment may be RAPID header
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
436 var l: number = nextnonblank(1)
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
437 while l > 0 && l < line('$') && getline(l) =~ '^\s*%' # LambdaProlog comment
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
438 l = nextnonblank(l + 1)
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
439 endwhile
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
440 # this pattern must not catch a go.mod file
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
441 return getline(l) =~ '\<module\s\+\w\+\s*\.\s*\(%\|$\)'
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
442 enddef
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
443
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
444 # Determine if *.mod is ABB RAPID, LambdaProlog, Modula-2, Modsim III or go.mod
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
445 export def FTmod()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
446 if exists("g:filetype_mod")
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
447 exe "setf " .. g:filetype_mod
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
448 elseif IsLProlog()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
449 setf lprolog
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
450 elseif getline(nextnonblank(1)) =~ '\%(\<MODULE\s\+\w\+\s*;\|^\s*(\*\)'
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
451 setf modula2
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
452 elseif IsRapid()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
453 setf rapid
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
454 elseif expand("<afile>") =~ '\<go.mod$'
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
455 setf gomod
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
456 else
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
457 # Nothing recognized, assume modsim3
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
458 setf modsim3
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
459 endif
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
460 enddef
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
461
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
462 export def FTpl()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
463 if exists("g:filetype_pl")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
464 exe "setf " .. g:filetype_pl
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
465 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
466 # recognize Prolog by specific text in the first non-empty line
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
467 # require a blank after the '%' because Perl uses "%list" and "%translate"
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
468 var l = getline(nextnonblank(1))
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
469 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
470 setf prolog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
471 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
472 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
473 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
474 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
475 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
476
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
477 export def FTinc()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
478 if exists("g:filetype_inc")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
479 exe "setf " .. g:filetype_inc
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
480 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
481 var lines = getline(1) .. getline(2) .. getline(3)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
482 if lines =~? "perlscript"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
483 setf aspperl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
484 elseif lines =~ "<%"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
485 setf aspvbs
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
486 elseif lines =~ "<?"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
487 setf php
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
488 # Pascal supports // comments but they're vary rarely used for file
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
489 # headers so assume POV-Ray
27845
e63514ae0c29 patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents: 27557
diff changeset
490 elseif lines =~ '^\s*\%({\|(\*\)' || lines =~? ft_pascal_keywords
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
491 setf pascal
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
492 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
493 FTasmsyntax()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
494 if exists("b:asmsyntax")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
495 exe "setf " .. fnameescape(b:asmsyntax)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
496 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
497 setf pov
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
498 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
499 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
500 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
501 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
502
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
503 export def FTprogress_cweb()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
504 if exists("g:filetype_w")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
505 exe "setf " .. g:filetype_w
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
506 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
507 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
508 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
509 setf progress
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
510 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
511 setf cweb
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
512 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
513 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
514
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
515 export def FTprogress_asm()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
516 if exists("g:filetype_i")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
517 exe "setf " .. g:filetype_i
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
518 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
519 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
520 # This function checks for an assembly comment the first ten lines.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
521 # If not found, assume Progress.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
522 var lnum = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
523 while lnum <= 10 && lnum < line('$')
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
524 var line = getline(lnum)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
525 if line =~ '^\s*;' || line =~ '^\*'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
526 FTasm()
12816
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 elseif line !~ '^\s*$' || line =~ '^/\*'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
529 # Not an empty line: Doesn't look like valid assembly code.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
530 # Or it looks like a Progress /* comment
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
531 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
532 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
533 lnum += 1
27972
9c0b7953016e patch 8.2.4511: filetype test fails
Bram Moolenaar <Bram@vim.org>
parents: 27903
diff changeset
534 endwhile
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
535 setf progress
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
536 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
537
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
538 var ft_pascal_comments = '^\s*\%({\|(\*\|//\)'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
539 var ft_pascal_keywords = '^\s*\%(program\|unit\|library\|uses\|begin\|procedure\|function\|const\|type\|var\)\>'
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
540
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
541 export def FTprogress_pascal()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
542 if exists("g:filetype_p")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
543 exe "setf " .. g:filetype_p
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
544 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
545 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
546 # This function checks for valid Pascal syntax in the first ten lines.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
547 # Look for either an opening comment or a program start.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
548 # If not found, assume Progress.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
549 var lnum = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
550 while lnum <= 10 && lnum < line('$')
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
551 var line = getline(lnum)
27845
e63514ae0c29 patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents: 27557
diff changeset
552 if line =~ ft_pascal_comments || line =~? ft_pascal_keywords
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
553 setf pascal
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
554 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
555 elseif line !~ '^\s*$' || line =~ '^/\*'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
556 # Not an empty line: Doesn't look like valid Pascal code.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
557 # Or it looks like a Progress /* comment
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
558 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
559 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
560 lnum += 1
27972
9c0b7953016e patch 8.2.4511: filetype test fails
Bram Moolenaar <Bram@vim.org>
parents: 27903
diff changeset
561 endwhile
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
562 setf progress
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
563 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
564
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
565 export def FTpp()
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
566 if exists("g:filetype_pp")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
567 exe "setf " .. g:filetype_pp
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
568 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
569 var line = getline(nextnonblank(1))
27845
e63514ae0c29 patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents: 27557
diff changeset
570 if line =~ ft_pascal_comments || line =~? ft_pascal_keywords
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
571 setf pascal
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
572 else
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
573 setf puppet
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
574 endif
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
575 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
576 enddef
23584
397f95f103e8 patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents: 21991
diff changeset
577
28390
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
578 # Determine if *.prg is ABB RAPID. Can also be Clipper, FoxPro or eviews
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
579 export def FTprg()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
580 if exists("g:filetype_prg")
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
581 exe "setf " .. g:filetype_prg
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
582 elseif IsRapid()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
583 setf rapid
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
584 else
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
585 # Nothing recognized, assume Clipper
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
586 setf clipper
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
587 endif
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
588 enddef
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
589
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
590 export def FTr()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
591 var max = line("$") > 50 ? 50 : line("$")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
592
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
593 for n in range(1, max)
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
594 # Rebol is easy to recognize, check for that first
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
595 if getline(n) =~? '\<REBOL\>'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
596 setf rebol
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
597 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
598 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
599 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
600
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
601 for n in range(1, max)
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
602 # R has # comments
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
603 if getline(n) =~ '^\s*#'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
604 setf r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
605 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
606 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
607 # Rexx has /* comments */
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
608 if getline(n) =~ '^\s*/\*'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
609 setf rexx
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
610 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
611 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
612 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
613
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
614 # Nothing recognized, use user default or assume Rexx
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
615 if exists("g:filetype_r")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
616 exe "setf " .. g:filetype_r
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
617 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
618 # Rexx used to be the default, but R appears to be much more popular.
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
619 setf r
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
620 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
621 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
622
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
623 export def McSetf()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
624 # Rely on the file to start with a comment.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
625 # MS message text files use ';', Sendmail files use '#' or 'dnl'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
626 for lnum in range(1, min([line("$"), 20]))
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
627 var line = getline(lnum)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
628 if line =~ '^\s*\(#\|dnl\)'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
629 setf m4 # Sendmail .mc file
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
630 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
631 elseif line =~ '^\s*;'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
632 setf msmessages # MS Message text file
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
633 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
634 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
635 endfor
28390
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
636 setf m4 # Default: Sendmail .mc file
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
637 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
638
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
639 # Called from filetype.vim and scripts.vim.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
640 export def SetFileTypeSH(name: string)
15527
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
641 if did_filetype()
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
642 # Filetype was already detected
15527
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
643 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
644 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
645 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
646 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
647 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
648 if name =~ '\<csh\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
649 # Some .sh scripts contain #!/bin/csh.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
650 SetFileTypeShell("csh")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
651 return
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
652 elseif name =~ '\<tcsh\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
653 # Some .sh scripts contain #!/bin/tcsh.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
654 SetFileTypeShell("tcsh")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
655 return
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
656 elseif name =~ '\<zsh\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
657 # Some .sh scripts contain #!/bin/zsh.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
658 SetFileTypeShell("zsh")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
659 return
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
660 elseif name =~ '\<ksh\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
661 b:is_kornshell = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
662 if exists("b:is_bash")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
663 unlet b:is_bash
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
664 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
665 if exists("b:is_sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
666 unlet b:is_sh
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
667 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
668 elseif exists("g:bash_is_sh") || name =~ '\<bash\>' || name =~ '\<bash2\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
669 b:is_bash = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
670 if exists("b:is_kornshell")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
671 unlet b:is_kornshell
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
672 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
673 if exists("b:is_sh")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
674 unlet b:is_sh
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
675 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
676 elseif name =~ '\<sh\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
677 b:is_sh = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
678 if exists("b:is_kornshell")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
679 unlet b:is_kornshell
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 if exists("b:is_bash")
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
682 unlet b:is_bash
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
683 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
684 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
685 SetFileTypeShell("sh")
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
686 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
687
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
688 # For shell-like file types, check for an "exec" command hidden in a comment,
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
689 # as used for Tcl.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
690 # Also called from scripts.vim, thus can't be local to this script.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
691 export def SetFileTypeShell(name: string)
15527
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
692 if did_filetype()
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
693 # Filetype was already detected
15527
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
694 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
695 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
696 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
697 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
698 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
699 var l = 2
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
700 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
701 # Skip empty and comment lines.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
702 l += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
703 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
704 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
705 # Found an "exec" line after a comment with continuation
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
706 var n = substitute(getline(l), '\s*exec\s\+\([^ ]*/\)\=', '', '')
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
707 if n =~ '\<tclsh\|\<wish'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
708 setf tcl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
709 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
710 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
711 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
712 exe "setf " .. name
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
713 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
714
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
715 export def CSH()
15527
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
716 if did_filetype()
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
717 # Filetype was already detected
15527
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
718 return
963dd629d19a patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents: 14999
diff changeset
719 endif
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
720 if exists("g:filetype_csh")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
721 SetFileTypeShell(g:filetype_csh)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
722 elseif &shell =~ "tcsh"
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
723 SetFileTypeShell("tcsh")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
724 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
725 SetFileTypeShell("csh")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
726 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
727 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
728
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
729 var ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
730 export def FTRules()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
731 var 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
732 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
733 setf udevrules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
734 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
735 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
736 if path =~ '^/etc/ufw/'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
737 setf conf # Better than hog
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
738 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
739 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
740 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
741 setf javascript
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
742 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
743 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
744 var config_lines: list<string>
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
745 try
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
746 config_lines = readfile('/etc/udev/udev.conf')
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
747 catch /^Vim\%((\a\+)\)\=:E484/
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
748 setf hog
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
749 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
750 endtry
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
751 var dir = expand('<amatch>:p:h')
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
752 for line in config_lines
27845
e63514ae0c29 patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents: 27557
diff changeset
753 if line =~ ft_rules_udev_rules_pattern
e63514ae0c29 patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents: 27557
diff changeset
754 var udev_rules = substitute(line, ft_rules_udev_rules_pattern, '\1', "")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
755 if dir == udev_rules
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
756 setf udevrules
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 break
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
759 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
760 endfor
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
761 setf hog
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
762 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
763
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
764 export def SQL()
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
765 if exists("g:filetype_sql")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
766 exe "setf " .. g:filetype_sql
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
767 else
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
768 setf sql
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
769 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
770 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
771
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
772 # If the file has an extension of 't' and is in a directory 't' or 'xt' then
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
773 # it is almost certainly a Perl test file.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
774 # If the first line starts with '#' and contains 'perl' it's probably a Perl
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
775 # file.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
776 # (Slow test) If a file contains a 'use' statement then it is almost certainly
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
777 # a Perl file.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
778 export def FTperl(): number
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
779 var dirname = expand("%:p:h:t")
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
780 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
781 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
782 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
783 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
784 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
785 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
786 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
787 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
788 var save_cursor = getpos('.')
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
789 call cursor(1, 1)
27557
ce72087b601f patch 8.2.4305: tex filetype detection fails
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
790 var has_use = search('^use\s\s*\k', 'c', 30) > 0
13051
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
791 call setpos('.', save_cursor)
a6d3e2081544 Update runtime files
Christian Brabandt <cb@256bit.org>
parents: 12816
diff changeset
792 if has_use
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
793 setf perl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
794 return 1
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
795 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
796 return 0
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
797 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
798
28390
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
799 export def FTsys()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
800 if IsRapid()
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
801 setf rapid
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
802 else
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
803 setf bat
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
804 endif
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
805 enddef
cc4d3ded4004 patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents: 28379
diff changeset
806
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
807 # Choose context, plaintex, or tex (LaTeX) based on these rules:
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
808 # 1. Check the first line of the file for "%&<format>".
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
809 # 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
810 # 3. Default to "plain" or to g:tex_flavor, can be set in user's vimrc.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
811 export def FTtex()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
812 var firstline = getline(1)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
813 var format: string
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
814 if firstline =~ '^%&\s*\a\+'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
815 format = tolower(matchstr(firstline, '\a\+'))
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
816 format = substitute(format, 'pdf', '', '')
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
817 if format == 'tex'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
818 format = 'latex'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
819 elseif format == 'plaintex'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
820 format = 'plain'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
821 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
822 elseif expand('%') =~ 'tex/context/.*/.*.tex'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
823 format = 'context'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
824 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
825 # Default value, may be changed later:
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
826 format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
827 # Save position, go to the top of the file, find first non-comment line.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
828 var save_cursor = getpos('.')
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
829 call cursor(1, 1)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
830 var firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
27557
ce72087b601f patch 8.2.4305: tex filetype detection fails
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
831 if firstNC > 0
ce72087b601f patch 8.2.4305: tex filetype detection fails
Bram Moolenaar <Bram@vim.org>
parents: 27538
diff changeset
832 # Check the next thousand lines for a LaTeX or ConTeXt keyword.
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
833 var lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
834 var 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\>'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
835 var kwline = search('^\s*\\\%(' .. lpat .. '\)\|^\s*\\\(' .. cpat .. '\)',
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
836 'cnp', firstNC + 1000)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
837 if kwline == 1 # lpat matched
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
838 format = 'latex'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
839 elseif kwline == 2 # cpat matched
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
840 format = 'context'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
841 endif # If neither matched, keep default set above.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
842 # let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
843 # let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
844 # if cline > 0
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
845 # let format = 'context'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
846 # endif
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
847 # if lline > 0 && (cline == 0 || cline > lline)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
848 # let format = 'tex'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
849 # endif
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
850 endif # firstNC
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
851 call setpos('.', save_cursor)
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
852 endif # firstline =~ '^%&\s*\a\+'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
853
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
854 # Translation from formats to file types. TODO: add AMSTeX, RevTex, others?
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
855 if format == 'plain'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
856 setf plaintex
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
857 elseif format == 'context'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
858 setf context
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
859 else # probably LaTeX
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
860 setf tex
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
861 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
862 return
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
863 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
864
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
865 export def FTxml()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
866 var n = 1
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
867 while n < 100 && n <= line("$")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
868 var line = getline(n)
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
869 # DocBook 4 or DocBook 5.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
870 var is_docbook4 = line =~ '<!DOCTYPE.*DocBook'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
871 var is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"'
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
872 if is_docbook4 || is_docbook5
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
873 b:docbk_type = "xml"
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
874 if is_docbook5
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
875 b:docbk_ver = 5
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
876 else
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
877 b:docbk_ver = 4
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
878 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
879 setf docbk
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
880 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
881 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
882 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
883 setf xbl
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
884 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
885 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
886 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
887 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
888 setf xml
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
889 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
890
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
891 export def FTy()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
892 var n = 1
16024
7fd3a9eaeedb patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents: 15527
diff changeset
893 while n < 100 && n <= line("$")
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
894 var line = getline(n)
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
895 if line =~ '^\s*%'
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
896 setf yacc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
897 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
898 endif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
899 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
900 setf racc
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
901 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
902 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
903 n += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
904 endwhile
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
905 setf yacc
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
906 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
907
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
908 export def Redif()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
909 var lnum = 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
910 while lnum <= 5 && lnum < line('$')
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
911 if getline(lnum) =~ "^\ctemplate-type:"
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
912 setf redif
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
913 return
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
914 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
915 lnum += 1
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
916 endwhile
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
917 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
918
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
919 # This function is called for all files under */debian/patches/*, make sure not
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
920 # to non-dep3patch files, such as README and other text files.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
921 export def Dep3patch()
26628
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
922 if expand('%:t') ==# 'series'
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
923 return
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
924 endif
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
925
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
926 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
927 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
928 setf dep3patch
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
929 return
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
930 elseif ln =~# '^---'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
931 # end of headers found. stop processing
26628
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
932 return
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
933 endif
7efd8f561d04 patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents: 26438
diff changeset
934 endfor
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
935 enddef
12816
218102da5226 patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
936
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
937 # This function checks the first 15 lines for appearance of 'FoamFile'
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
938 # and then 'object' in a following line.
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
939 # In that case, it's probably an OpenFOAM file
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
940 export def FTfoam()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
941 var ffile = 0
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
942 var lnum = 1
27070
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
943 while lnum <= 15
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
944 if getline(lnum) =~# '^FoamFile'
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
945 ffile = 1
27070
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
946 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
947 setf foam
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
948 return
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
949 endif
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
950 lnum += 1
27070
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
951 endwhile
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
952 enddef
27070
b353bd9faec8 patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents: 26708
diff changeset
953
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
954 # Determine if a *.tf file is TF mud client or terraform
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
955 export def FTtf()
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
956 var numberOfLines = line('$')
27420
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
957 for i in range(1, numberOfLines)
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
958 var currentLine = trim(getline(i))
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
959 var firstCharacter = currentLine[0]
27420
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
960 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
961 setf terraform
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
962 return
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
963 endif
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
964 endfor
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
965 setf tf
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
966 enddef
27420
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
967
28351
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
968 # Determine if a *.src file is Kuka Robot Language
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
969 export def FTsrc()
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
970 if exists("g:filetype_src")
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
971 exe "setf " .. g:filetype_src
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
972 elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|\%(global\s\+\)\?def\>\)'
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
973 setf krl
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
974 endif
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
975 enddef
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
976
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
977 # Determine if a *.dat file is Kuka Robot Language
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
978 export def FTdat()
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
979 if exists("g:filetype_dat")
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
980 exe "setf " .. g:filetype_dat
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
981 elseif getline(nextnonblank(1)) =~? '^\s*\%(&\w\+\|defdat\>\)'
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
982 setf krl
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
983 endif
1aa3460f799d patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents: 28010
diff changeset
984 enddef
27420
978890380129 patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents: 27287
diff changeset
985
27537
063952f68595 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 27493
diff changeset
986 # Uncomment this line to check for compilation errors early
27538
f37561549ec2 Update runtime files; use compiled functions
Bram Moolenaar <Bram@vim.org>
parents: 27537
diff changeset
987 # defcompile