Mercurial > vim
annotate runtime/autoload/dist/ft.vim @ 28871:18604231a1d1 v8.2.4958
patch 8.2.4958: a couple conditions are always true
Commit: https://github.com/vim/vim/commit/dd41037552c1be3548d2ce34bb1c889f14edb553
Author: =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com>
Date: Sun May 15 13:59:11 2022 +0100
patch 8.2.4958: a couple conditions are always true
Problem: A couple conditions are always true.
Solution: Remove the conditions. (Goc Dundar, closes https://github.com/vim/vim/issues/10428)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 15 May 2022 15:00:02 +0200 |
parents | f73a9bdff3a3 |
children | 1f1d99bba06c |
rev | line source |
---|---|
27537 | 1 vim9script |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
27537 | 3 # Vim functions for file type detection |
4 # | |
5 # Maintainer: Bram Moolenaar <Bram@vim.org> | |
28517 | 6 # Last Change: 2022 Apr 13 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
27537 | 8 # These functions are moved here from runtime/filetype.vim to make startup |
9 # faster. | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
27537 | 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 | 15 var n = 1 |
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 | 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 | 25 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 |
27537 | 27 # This function checks for the kind of assembly that is wanted by the user, or |
28 # can be detected from the first five lines of the file. | |
29 export def FTasm() | |
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 | 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 | 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 | 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 | 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 | 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 | 48 exe "setf " .. fnameescape(b:asmsyntax) |
49 enddef | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 |
27537 | 51 export def FTasmsyntax() |
52 # see if the file contains any asmsyntax=foo overrides. If so, change | |
53 # b:asmsyntax appropriately | |
54 var head = " " .. getline(1) .. " " .. getline(2) .. " " | |
55 .. getline(3) .. " " .. getline(4) .. " " .. getline(5) .. " " | |
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 | 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 | 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 | 62 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 |
27537 | 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 | 66 # See FTfrm() for Visual Basic form file detection |
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 | 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 | 73 # most frequent FreeBASIC-specific keywords in distro files |
74 var fb_keywords = '\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!' | |
75 var fb_preproc = '\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)' | |
76 var fb_comment = "^\\s*/'" | |
77 # OPTION EXPLICIT, without the leading underscore, is common to many dialects | |
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 | 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 | 91 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 |
27537 | 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 | 99 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 |
27537 | 101 export def BindzoneCheck(default = '') |
102 if getline(1) .. getline(2) .. getline(3) .. getline(4) | |
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 | 105 elseif default != '' |
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 | 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 | 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 | 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 | 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 | 141 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 |
27537 | 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 | 157 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
158 |
27537 | 159 # This function checks if one of the first ten lines start with a '@'. In |
160 # that case it is probably a change file. | |
161 # If the first line starts with # or ! it's probably a ch file. | |
162 # If a line has "main", "include", "//" or "/*" it's probably ch. | |
163 # Otherwise CHILL is assumed. | |
164 export def FTchange() | |
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 | 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 | 186 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
187 |
27537 | 188 export def FTent() |
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 | 191 # If not found, assume SGML. |
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 | 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 | 199 # Not a blank line, not a comment, and not a block start, |
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 | 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 | 206 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 |
27537 | 208 export def ExCheck() |
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 | 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 | 217 enddef |
25026
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
218 |
27537 | 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 | 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 | 225 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 |
27537 | 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 | 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 | 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 | 241 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
242 |
27537 | 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 | 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 | 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 | 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 | 257 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
258 |
27537 | 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 | 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 | 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 | 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 | 274 # Distinguish between Forth and F#. |
275 # Provided by Doug Kearns. | |
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 | 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 | 280 var line = getline(nextnonblank(1)) |
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 | 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 | 291 # Distinguish between HTML, XHTML and Django |
292 export def FThtml() | |
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 | 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 | 306 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
307 |
27537 | 308 # Distinguish between standard IDL and MS-IDL |
309 export def FTidl() | |
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 | 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 | 319 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
320 |
27537 | 321 # Distinguish between "default" and Cproto prototype file. */ |
322 export def ProtoCheck(default: string) | |
323 # Cproto files have a comment in the first line and a function prototype in | |
324 # the second line, it always ends in ";". Indent files may also have | |
325 # comments, thus we can't match comments to see the difference. | |
326 # IDL files can have a single ';' in the second line, require at least one | |
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 | 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 | 333 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
334 |
27537 | 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 | 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 | 341 # excluding end(for|function|if|switch|while) common to Murphi |
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 | 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 | 346 var n = 1 |
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 | 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 | 351 # /* ... */ is a comment in Objective C and Murphi, so we can't conclude |
352 # it's either of them yet, but track this as a hint in case we don't see | |
353 # anything more definitive. | |
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 | 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 | 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 | 382 # We didn't see anything definitive, but this looks like either Objective C |
383 # or Murphi based on the comment leader. Assume the former as it is more | |
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 | 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 | 390 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
391 |
27537 | 392 export def FTmms() |
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 | 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 | 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 | 407 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
408 |
27537 | 409 # This function checks if one of the first five lines start with a dot. In |
410 # that case it is probably an nroff file: 'filetype' is set and 1 is returned. | |
411 export def FTnroff(): number | |
412 if getline(1)[0] .. getline(2)[0] .. getline(3)[0] | |
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 | 418 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
419 |
27537 | 420 export def FTmm() |
421 var n = 1 | |
19968 | 422 while n < 20 |
27537 | 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 | 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 | 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 | 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 | 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 | 466 # recognize Prolog by specific text in the first non-empty line |
467 # require a blank after the '%' because Perl uses "%list" and "%translate" | |
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 | 475 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
476 |
27537 | 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 | 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 | 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 | 488 # Pascal supports // comments but they're vary rarely used for file |
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 | 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 | 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 | 501 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
502 |
27537 | 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 | 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 | 513 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
514 |
27537 | 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 | 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 | 520 # This function checks for an assembly comment the first ten lines. |
521 # If not found, assume Progress. | |
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 | 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 | 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 | 529 # Not an empty line: Doesn't look like valid assembly code. |
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 | 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 | 536 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
537 |
27537 | 538 var ft_pascal_comments = '^\s*\%({\|(\*\|//\)' |
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 | 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 | 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 | 546 # This function checks for valid Pascal syntax in the first ten lines. |
547 # Look for either an opening comment or a program start. | |
548 # If not found, assume Progress. | |
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 | 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 | 556 # Not an empty line: Doesn't look like valid Pascal code. |
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 | 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 | 563 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
564 |
27537 | 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 | 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 | 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 | 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 | 590 export def FTr() |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 621 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
622 |
27537 | 623 export def McSetf() |
624 # Rely on the file to start with a comment. | |
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 | 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 | 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 | 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 | 637 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
638 |
27537 | 639 # Called from filetype.vim and scripts.vim. |
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 | 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 | 648 if name =~ '\<csh\>' |
649 # Some .sh scripts contain #!/bin/csh. | |
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 | 652 elseif name =~ '\<tcsh\>' |
653 # Some .sh scripts contain #!/bin/tcsh. | |
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 | 656 elseif name =~ '\<zsh\>' |
657 # Some .sh scripts contain #!/bin/zsh. | |
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 | 660 elseif name =~ '\<ksh\>' |
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 | 668 elseif exists("g:bash_is_sh") || name =~ '\<bash\>' || name =~ '\<bash2\>' |
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 | 676 elseif name =~ '\<sh\>' |
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 | 685 SetFileTypeShell("sh") |
686 enddef | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
687 |
27537 | 688 # For shell-like file types, check for an "exec" command hidden in a comment, |
689 # as used for Tcl. | |
690 # Also called from scripts.vim, thus can't be local to this script. | |
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 | 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 | 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 | 701 # Skip empty and comment lines. |
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 | 705 # Found an "exec" line after a comment with continuation |
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 | 712 exe "setf " .. name |
713 enddef | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
714 |
27537 | 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 | 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 | 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 | 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 | 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 | 727 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
728 |
27537 | 729 var ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' |
730 export def FTRules() | |
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 | 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 | 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 | 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 | 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 | 762 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
763 |
27537 | 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 | 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 | 770 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
771 |
28443
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
772 # This function checks the first 25 lines of file extension "sc" to resolve |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
773 # detection between scala and SuperCollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
774 export def FTsc() |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
775 for lnum in range(1, min([line("$"), 25])) |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
776 if getline(lnum) =~# '[A-Za-z0-9]*\s:\s[A-Za-z0-9]\|var\s<\|classvar\s<\|\^this.*\||\w*|\|+\s\w*\s{\|\*ar\s' |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
777 setf supercollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
778 return |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
779 endif |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
780 endfor |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
781 setf scala |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
782 enddef |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
783 |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
784 # This function checks the first line of file extension "scd" to resolve |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
785 # detection between scdoc and SuperCollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
786 export def FTscd() |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
787 if getline(1) =~# '\%^\S\+(\d[0-9A-Za-z]*)\%(\s\+\"[^"]*\"\%(\s\+\"[^"]*\"\)\=\)\=$' |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
788 setf scdoc |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
789 else |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
790 setf supercollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
791 endif |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
792 enddef |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
793 |
27537 | 794 # If the file has an extension of 't' and is in a directory 't' or 'xt' then |
795 # it is almost certainly a Perl test file. | |
796 # If the first line starts with '#' and contains 'perl' it's probably a Perl | |
797 # file. | |
798 # (Slow test) If a file contains a 'use' statement then it is almost certainly | |
799 # a Perl file. | |
800 export def FTperl(): number | |
801 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
|
802 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
|
803 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
804 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
805 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
806 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
|
807 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
808 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
809 endif |
27537 | 810 var save_cursor = getpos('.') |
811 call cursor(1, 1) | |
27557
ce72087b601f
patch 8.2.4305: tex filetype detection fails
Bram Moolenaar <Bram@vim.org>
parents:
27538
diff
changeset
|
812 var has_use = search('^use\s\s*\k', 'c', 30) > 0 |
13051 | 813 call setpos('.', save_cursor) |
814 if has_use | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
815 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
816 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
817 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
818 return 0 |
27537 | 819 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
820 |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
821 export def FTsys() |
28445
7f0ec490d608
patch 8.2.4747: no filetype override for .sys files
Bram Moolenaar <Bram@vim.org>
parents:
28443
diff
changeset
|
822 if exists("g:filetype_sys") |
7f0ec490d608
patch 8.2.4747: no filetype override for .sys files
Bram Moolenaar <Bram@vim.org>
parents:
28443
diff
changeset
|
823 exe "setf " .. g:filetype_sys |
7f0ec490d608
patch 8.2.4747: no filetype override for .sys files
Bram Moolenaar <Bram@vim.org>
parents:
28443
diff
changeset
|
824 elseif IsRapid() |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
825 setf rapid |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
826 else |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
827 setf bat |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
828 endif |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
829 enddef |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
830 |
27537 | 831 # Choose context, plaintex, or tex (LaTeX) based on these rules: |
832 # 1. Check the first line of the file for "%&<format>". | |
833 # 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. | |
834 # 3. Default to "plain" or to g:tex_flavor, can be set in user's vimrc. | |
835 export def FTtex() | |
836 var firstline = getline(1) | |
837 var format: string | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
838 if firstline =~ '^%&\s*\a\+' |
27537 | 839 format = tolower(matchstr(firstline, '\a\+')) |
840 format = substitute(format, 'pdf', '', '') | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
841 if format == 'tex' |
27537 | 842 format = 'latex' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
843 elseif format == 'plaintex' |
27537 | 844 format = 'plain' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
845 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
846 elseif expand('%') =~ 'tex/context/.*/.*.tex' |
27537 | 847 format = 'context' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
848 else |
27537 | 849 # Default value, may be changed later: |
850 format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' | |
851 # Save position, go to the top of the file, find first non-comment line. | |
852 var save_cursor = getpos('.') | |
853 call cursor(1, 1) | |
854 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
|
855 if firstNC > 0 |
ce72087b601f
patch 8.2.4305: tex filetype detection fails
Bram Moolenaar <Bram@vim.org>
parents:
27538
diff
changeset
|
856 # Check the next thousand lines for a LaTeX or ConTeXt keyword. |
27537 | 857 var lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' |
858 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\>' | |
859 var kwline = search('^\s*\\\%(' .. lpat .. '\)\|^\s*\\\(' .. cpat .. '\)', | |
860 'cnp', firstNC + 1000) | |
861 if kwline == 1 # lpat matched | |
862 format = 'latex' | |
863 elseif kwline == 2 # cpat matched | |
864 format = 'context' | |
865 endif # If neither matched, keep default set above. | |
866 # let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) | |
867 # let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) | |
868 # if cline > 0 | |
869 # let format = 'context' | |
870 # endif | |
871 # if lline > 0 && (cline == 0 || cline > lline) | |
872 # let format = 'tex' | |
873 # endif | |
874 endif # firstNC | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
875 call setpos('.', save_cursor) |
27537 | 876 endif # firstline =~ '^%&\s*\a\+' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
877 |
27537 | 878 # 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
|
879 if format == 'plain' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
880 setf plaintex |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
881 elseif format == 'context' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
882 setf context |
27537 | 883 else # probably LaTeX |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
884 setf tex |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
885 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
886 return |
27537 | 887 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
888 |
27537 | 889 export def FTxml() |
890 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
|
891 while n < 100 && n <= line("$") |
27537 | 892 var line = getline(n) |
893 # DocBook 4 or DocBook 5. | |
894 var is_docbook4 = line =~ '<!DOCTYPE.*DocBook' | |
895 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
|
896 if is_docbook4 || is_docbook5 |
27537 | 897 b:docbk_type = "xml" |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
898 if is_docbook5 |
27537 | 899 b:docbk_ver = 5 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
900 else |
27537 | 901 b:docbk_ver = 4 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
902 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
903 setf docbk |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
904 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
905 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
906 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
|
907 setf xbl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
908 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
909 endif |
27537 | 910 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
911 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
912 setf xml |
27537 | 913 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
914 |
27537 | 915 export def FTy() |
916 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
|
917 while n < 100 && n <= line("$") |
27537 | 918 var line = getline(n) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
919 if line =~ '^\s*%' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
920 setf yacc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
921 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
922 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
923 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
|
924 setf racc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
925 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
926 endif |
27537 | 927 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
928 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
929 setf yacc |
27537 | 930 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
931 |
27537 | 932 export def Redif() |
933 var lnum = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
934 while lnum <= 5 && lnum < line('$') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
935 if getline(lnum) =~ "^\ctemplate-type:" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
936 setf redif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
937 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
938 endif |
27537 | 939 lnum += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
940 endwhile |
27537 | 941 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
942 |
27537 | 943 # This function is called for all files under */debian/patches/*, make sure not |
944 # to non-dep3patch files, such as README and other text files. | |
945 export def Dep3patch() | |
26628
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
946 if expand('%:t') ==# 'series' |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
947 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
948 endif |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
949 |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
950 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
|
951 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
|
952 setf dep3patch |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
953 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
954 elseif ln =~# '^---' |
27537 | 955 # 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
|
956 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
957 endif |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
958 endfor |
27537 | 959 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
960 |
27537 | 961 # This function checks the first 15 lines for appearance of 'FoamFile' |
962 # and then 'object' in a following line. | |
963 # In that case, it's probably an OpenFOAM file | |
964 export def FTfoam() | |
965 var ffile = 0 | |
966 var lnum = 1 | |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
967 while lnum <= 15 |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
968 if getline(lnum) =~# '^FoamFile' |
27537 | 969 ffile = 1 |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
970 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
|
971 setf foam |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
972 return |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
973 endif |
27537 | 974 lnum += 1 |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
975 endwhile |
27537 | 976 enddef |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
977 |
27537 | 978 # Determine if a *.tf file is TF mud client or terraform |
979 export def FTtf() | |
980 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
|
981 for i in range(1, numberOfLines) |
27537 | 982 var currentLine = trim(getline(i)) |
983 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
|
984 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
|
985 setf terraform |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
986 return |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
987 endif |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
988 endfor |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
989 setf tf |
27537 | 990 enddef |
27420
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
991 |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
992 var ft_krl_header = '\&\w+' |
28351
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
993 # 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
|
994 export def FTsrc() |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
995 var ft_krl_def_or_deffct = '%(global\s+)?def%(fct)?>' |
28351
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
996 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
|
997 exe "setf " .. g:filetype_src |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
998 elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. ft_krl_header .. '|' .. ft_krl_def_or_deffct .. ')' |
28351
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
999 setf krl |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1000 endif |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1001 enddef |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1002 |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1003 # 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
|
1004 export def FTdat() |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
1005 var ft_krl_defdat = 'defdat>' |
28351
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1006 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
|
1007 exe "setf " .. g:filetype_dat |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
1008 elseif getline(nextnonblank(1)) =~? '\v^\s*%(' .. ft_krl_header .. '|' .. ft_krl_defdat .. ')' |
28351
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1009 setf krl |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1010 endif |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1011 enddef |
27420
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
1012 |
27537 | 1013 # 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
|
1014 # defcompile |