Mercurial > vim
annotate runtime/autoload/dist/ft.vim @ 30890:ebcaf6bbb410 v9.0.0779
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Commit: https://github.com/vim/vim/commit/4ac8e7948cb3e07bc4598ede8b274891d14dfa7c
Author: Doug Kearns <dougkearns@gmail.com>
Date: Mon Oct 17 13:32:17 2022 +0100
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Problem: lsl and lm3 file extensions are not recognized.
Solution: Add *.lsl and *.lm3 patterns. (Doug Kearns, closes https://github.com/vim/vim/issues/11384)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 Oct 2022 14:45:08 +0200 |
parents | d4c8fdaa3ae7 |
children | 8a54e866a5db |
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*[:=(]\)\@!' | |
29326
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
75 var fb_preproc = '\c^\s*\%(' .. |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
76 # preprocessor |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
77 '#\s*\a\+\|' .. |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
78 # compiler option |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
79 'option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\|' .. |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
80 # metacommand |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
81 '\%(''\|rem\)\s*\$lang\>\|' .. |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
82 # default datatype |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
83 'def\%(byte\|longint\|short\|ubyte\|uint\|ulongint\|ushort\)\>' .. |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
84 '\)' |
27537 | 85 var fb_comment = "^\\s*/'" |
29326
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
86 |
27537 | 87 # OPTION EXPLICIT, without the leading underscore, is common to many dialects |
88 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
|
89 |
29326
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
90 for lnum in range(1, min([line("$"), 100])) |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
91 var line = getline(lnum) |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
92 if line =~ ft_visual_basic_content |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
93 setf vb |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
94 return |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
95 elseif line =~ fb_preproc || line =~ fb_comment || line =~ fb_keywords |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
96 setf freebasic |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
97 return |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
98 elseif line =~ qb64_preproc |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
99 setf qb64 |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
100 return |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
101 endif |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
102 endfor |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
103 setf basic |
27537 | 104 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 |
27537 | 106 export def FTbtm() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 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
|
108 setf dosbatch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 setf btm |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 endif |
27537 | 112 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 |
27537 | 114 export def BindzoneCheck(default = '') |
115 if getline(1) .. getline(2) .. getline(3) .. getline(4) | |
116 =~ '^; <<>> 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
|
117 setf bindzone |
27537 | 118 elseif default != '' |
119 exe 'setf ' .. default | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 endif |
27537 | 121 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
122 |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
123 # 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
|
124 def IsRapid(sChkExt: string = ""): bool |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
125 if sChkExt == "cfg" |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
126 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
|
127 endif |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
128 # 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
|
129 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
|
130 enddef |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
131 |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
132 export def FTcfg() |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
133 if exists("g:filetype_cfg") |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
134 exe "setf " .. g:filetype_cfg |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
135 elseif IsRapid("cfg") |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
136 setf rapid |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
137 else |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
138 setf cfg |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
139 endif |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
140 enddef |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
141 |
29326
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
142 export def FTcls() |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
143 if exists("g:filetype_cls") |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
144 exe "setf " .. g:filetype_cls |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
145 return |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
146 endif |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
147 |
30873
d4c8fdaa3ae7
patch 9.0.0771: cannot always tell the difference beween tex and rexx files
Bram Moolenaar <Bram@vim.org>
parents:
30023
diff
changeset
|
148 if getline(1) =~ '^\v%(\%|\\)' |
29326
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
149 setf tex |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
150 elseif getline(1)[0] == '#' && getline(1) =~ 'rexx' |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
151 setf rexx |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
152 elseif getline(1) == 'VERSION 1.0 CLASS' |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
153 setf vb |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
154 else |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
155 setf st |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
156 endif |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
157 enddef |
1f1d99bba06c
patch 9.0.0006: not all Visual Basic files are recognized
Bram Moolenaar <Bram@vim.org>
parents:
28517
diff
changeset
|
158 |
27537 | 159 export def FTlpc() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
160 if exists("g:lpc_syntax_for_c") |
27537 | 161 var lnum = 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
162 while lnum <= 12 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
163 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
|
164 setf lpc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
165 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
166 endif |
27537 | 167 lnum += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
168 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
169 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
170 setf c |
27537 | 171 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
172 |
27537 | 173 export def FTheader() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
174 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
|
175 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
|
176 setf objc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
177 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
178 setf objcpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
179 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
180 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
|
181 setf c |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 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
|
183 setf ch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
185 setf cpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
186 endif |
27537 | 187 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
188 |
27537 | 189 # This function checks if one of the first ten lines start with a '@'. In |
190 # that case it is probably a change file. | |
191 # If the first line starts with # or ! it's probably a ch file. | |
192 # If a line has "main", "include", "//" or "/*" it's probably ch. | |
193 # Otherwise CHILL is assumed. | |
194 export def FTchange() | |
195 var lnum = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
196 while lnum <= 10 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
197 if getline(lnum)[0] == '@' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
198 setf change |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
201 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
|
202 setf ch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
203 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
204 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
205 if getline(lnum) =~ "MODULE" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
206 setf chill |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
207 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
208 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
209 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
|
210 setf ch |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
211 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
212 endif |
27537 | 213 lnum += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
214 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
215 setf chill |
27537 | 216 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
217 |
27537 | 218 export def FTent() |
219 # 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
|
220 # Look for either an opening comment, '#', or a block start, '{'. |
27537 | 221 # If not found, assume SGML. |
222 var lnum = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
223 while lnum < 6 |
27537 | 224 var line = getline(lnum) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
225 if line =~ '^\s*[#{]' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
226 setf cl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
227 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
228 elseif line !~ '^\s*$' |
27537 | 229 # Not a blank line, not a comment, and not a block start, |
230 # 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
|
231 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
232 endif |
27537 | 233 lnum += 1 |
27972
9c0b7953016e
patch 8.2.4511: filetype test fails
Bram Moolenaar <Bram@vim.org>
parents:
27903
diff
changeset
|
234 endwhile |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
235 setf dtd |
27537 | 236 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
237 |
27537 | 238 export def ExCheck() |
239 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
|
240 if exists('g:filetype_euphoria') |
27537 | 241 exe 'setf ' .. g:filetype_euphoria |
25026
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
242 elseif match(lines, '^--\|^ifdef\>\|^include\>') > -1 |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
243 setf euphoria3 |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
244 else |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
245 setf elixir |
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
246 endif |
27537 | 247 enddef |
25026
fda44c0b4b7b
patch 8.2.3050: cannot recognize elixir files
Bram Moolenaar <Bram@vim.org>
parents:
23584
diff
changeset
|
248 |
27537 | 249 export def EuphoriaCheck() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
250 if exists('g:filetype_euphoria') |
27537 | 251 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
|
252 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
253 setf euphoria3 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
254 endif |
27537 | 255 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
256 |
27537 | 257 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
|
258 if did_filetype() |
834d3fba1e7c
patch 8.2.4464: Dtrace files are recognized as filetype D
Bram Moolenaar <Bram@vim.org>
parents:
27845
diff
changeset
|
259 # 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
|
260 return |
834d3fba1e7c
patch 8.2.4464: Dtrace files are recognized as filetype D
Bram Moolenaar <Bram@vim.org>
parents:
27845
diff
changeset
|
261 endif |
27537 | 262 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
|
263 if match(lines, '^module\>\|^import\>') > -1 |
27537 | 264 # 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
|
265 setf d |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
266 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
|
267 setf dtrace |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
268 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
269 setf d |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
270 endif |
27537 | 271 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
272 |
27537 | 273 export def FTe() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
274 if exists('g:filetype_euphoria') |
27537 | 275 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
|
276 else |
27537 | 277 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
|
278 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
|
279 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 setf specman |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 endif |
27537 | 283 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
284 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
285 setf eiffel |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
286 endif |
27537 | 287 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
288 |
27537 | 289 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
|
290 if exists("g:filetype_frm") |
27537 | 291 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
|
292 return |
3af3dee7e5d9
patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
27492
diff
changeset
|
293 endif |
3af3dee7e5d9
patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
27492
diff
changeset
|
294 |
27537 | 295 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
|
296 |
27845
e63514ae0c29
patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents:
27557
diff
changeset
|
297 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
|
298 setf vb |
3af3dee7e5d9
patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
27492
diff
changeset
|
299 else |
3af3dee7e5d9
patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
27492
diff
changeset
|
300 setf form |
3af3dee7e5d9
patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
27492
diff
changeset
|
301 endif |
27537 | 302 enddef |
27493
3af3dee7e5d9
patch 8.2.4274: Basic and form filetype detection is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
27492
diff
changeset
|
303 |
27537 | 304 # Distinguish between Forth and F#. |
305 # Provided by Doug Kearns. | |
306 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
|
307 if exists("g:filetype_fs") |
27537 | 308 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
|
309 else |
27537 | 310 var line = getline(nextnonblank(1)) |
311 # 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
|
312 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
|
313 \ || 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
|
314 setf forth |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
315 else |
26344
36f3a77e4b8c
patch 8.2.3703: most people call F# "fsharp" and not "fs"
Bram Moolenaar <Bram@vim.org>
parents:
26311
diff
changeset
|
316 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
|
317 endif |
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
318 endif |
27537 | 319 enddef |
26311
ce3678583211
patch 8.2.3686: filetype detection often mixes up Forth and F#
Bram Moolenaar <Bram@vim.org>
parents:
26296
diff
changeset
|
320 |
27537 | 321 # Distinguish between HTML, XHTML and Django |
322 export def FThtml() | |
323 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
|
324 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
|
325 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
|
326 setf xhtml |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
327 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
328 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
329 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
|
330 setf htmldjango |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
331 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
332 endif |
27537 | 333 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
334 endwhile |
16024
7fd3a9eaeedb
patch 8.1.1017: off-by-one error in filetype detection
Bram Moolenaar <Bram@vim.org>
parents:
15527
diff
changeset
|
335 setf FALLBACK html |
27537 | 336 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
337 |
27537 | 338 # Distinguish between standard IDL and MS-IDL |
339 export def FTidl() | |
340 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
|
341 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
|
342 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
|
343 setf msidl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
344 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
345 endif |
27537 | 346 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
347 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
348 setf idl |
27537 | 349 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
350 |
29659 | 351 # Distinguish between "default", Prolog and Cproto prototype file. |
27537 | 352 export def ProtoCheck(default: string) |
353 # Cproto files have a comment in the first line and a function prototype in | |
354 # the second line, it always ends in ";". Indent files may also have | |
355 # comments, thus we can't match comments to see the difference. | |
356 # IDL files can have a single ';' in the second line, require at least one | |
357 # chacter before the ';'. | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
358 if getline(2) =~ '.;$' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
359 setf cpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
360 else |
29659 | 361 # recognize Prolog by specific text in the first non-empty line |
362 # require a blank after the '%' because Perl uses "%list" and "%translate" | |
363 var l = getline(nextnonblank(1)) | |
364 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' | |
365 setf prolog | |
366 else | |
367 exe 'setf ' .. default | |
368 endif | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
369 endif |
27537 | 370 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
371 |
27537 | 372 export def FTm() |
25727
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
373 if exists("g:filetype_m") |
27537 | 374 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
|
375 return |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
376 endif |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
377 |
27537 | 378 # excluding end(for|function|if|switch|while) common to Murphi |
379 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
|
380 |
27537 | 381 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
|
382 |
27537 | 383 var n = 1 |
384 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
|
385 while n < 100 |
27537 | 386 var line = getline(n) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
387 if line =~ '^\s*/\*' |
27537 | 388 # /* ... */ is a comment in Objective C and Murphi, so we can't conclude |
389 # it's either of them yet, but track this as a hint in case we don't see | |
390 # anything more definitive. | |
391 saw_comment = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
392 endif |
26296
9f32ccdadd22
patch 8.2.3679: objc file detected as Octave
Bram Moolenaar <Bram@vim.org>
parents:
25794
diff
changeset
|
393 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
|
394 setf objc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
395 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
396 endif |
25794
374adc90efa5
patch 8.2.3432: octave/Matlab filetype detection does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25727
diff
changeset
|
397 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
|
398 \ line =~ '\%(^\|;\)\s*' .. octave_block_terminators |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
399 setf octave |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
400 return |
71d3ebfb00b6
patch 8.2.3399: Octave files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
25026
diff
changeset
|
401 endif |
27537 | 402 # 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
|
403 if line =~ '^\s*%' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
404 setf matlab |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
405 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
406 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
407 if line =~ '^\s*(\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
408 setf mma |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
409 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
410 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
411 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
|
412 setf murphi |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
413 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
414 endif |
27537 | 415 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
416 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
417 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
418 if saw_comment |
27537 | 419 # We didn't see anything definitive, but this looks like either Objective C |
420 # or Murphi based on the comment leader. Assume the former as it is more | |
421 # common. | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
422 setf objc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
423 else |
27537 | 424 # Default is Matlab |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
425 setf matlab |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
426 endif |
27537 | 427 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
428 |
27537 | 429 export def FTmms() |
430 var n = 1 | |
19039
d20ed2e5a776
Update a few runtime files.
Bram Moolenaar <Bram@vim.org>
parents:
16086
diff
changeset
|
431 while n < 20 |
27537 | 432 var line = getline(n) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
433 if line =~ '^\s*\(%\|//\)' || line =~ '^\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
434 setf mmix |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
435 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
436 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
437 if line =~ '^\s*#' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
438 setf make |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
439 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
440 endif |
27537 | 441 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
442 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
443 setf mmix |
27537 | 444 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
445 |
27537 | 446 # This function checks if one of the first five lines start with a dot. In |
447 # that case it is probably an nroff file: 'filetype' is set and 1 is returned. | |
448 export def FTnroff(): number | |
449 if getline(1)[0] .. getline(2)[0] .. getline(3)[0] | |
450 .. 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
|
451 setf nroff |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
452 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
453 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
454 return 0 |
27537 | 455 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
456 |
27537 | 457 export def FTmm() |
458 var n = 1 | |
19968 | 459 while n < 20 |
27537 | 460 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
|
461 setf objcpp |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
462 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
463 endif |
27537 | 464 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
465 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
466 setf nroff |
27537 | 467 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
468 |
29338
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
469 # Returns true if file content looks like LambdaProlog module |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
470 def IsLProlog(): bool |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
471 # 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
|
472 # 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
|
473 var l: number = nextnonblank(1) |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
474 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
|
475 l = nextnonblank(l + 1) |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
476 endwhile |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
477 # 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
|
478 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
|
479 enddef |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
480 |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
481 # 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
|
482 export def FTmod() |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
483 if exists("g:filetype_mod") |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
484 exe "setf " .. g:filetype_mod |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
485 elseif IsLProlog() |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
486 setf lprolog |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
487 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
|
488 setf modula2 |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
489 elseif IsRapid() |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
490 setf rapid |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
491 elseif expand("<afile>") =~ '\<go.mod$' |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
492 setf gomod |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
493 else |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
494 # Nothing recognized, assume modsim3 |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
495 setf modsim3 |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
496 endif |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
497 enddef |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
498 |
27537 | 499 export def FTpl() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
500 if exists("g:filetype_pl") |
27537 | 501 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
|
502 else |
27537 | 503 # recognize Prolog by specific text in the first non-empty line |
504 # require a blank after the '%' because Perl uses "%list" and "%translate" | |
505 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
|
506 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
|
507 setf prolog |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
508 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
509 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
510 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
511 endif |
27537 | 512 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
513 |
27537 | 514 export def FTinc() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
515 if exists("g:filetype_inc") |
27537 | 516 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
|
517 else |
27537 | 518 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
|
519 if lines =~? "perlscript" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
520 setf aspperl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
521 elseif lines =~ "<%" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
522 setf aspvbs |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
523 elseif lines =~ "<?" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
524 setf php |
27537 | 525 # Pascal supports // comments but they're vary rarely used for file |
526 # headers so assume POV-Ray | |
27845
e63514ae0c29
patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents:
27557
diff
changeset
|
527 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
|
528 setf pascal |
29493
6c1e06abff2c
patch 9.0.0088: pattern for detecting bitbake files is not sufficient
Bram Moolenaar <Bram@vim.org>
parents:
29427
diff
changeset
|
529 elseif lines =~# '\<\%(require\|inherit\)\>' || lines =~# '[A-Z][A-Za-z0-9_:${}]*\s\+\%(??\|[?:+]\)\?= ' |
29427
2830faa3e100
patch 9.0.0055: bitbake files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
29338
diff
changeset
|
530 setf bitbake |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
531 else |
27537 | 532 FTasmsyntax() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
533 if exists("b:asmsyntax") |
29427
2830faa3e100
patch 9.0.0055: bitbake files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
29338
diff
changeset
|
534 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
|
535 else |
29427
2830faa3e100
patch 9.0.0055: bitbake files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
29338
diff
changeset
|
536 setf pov |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
537 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
538 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
539 endif |
27537 | 540 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
541 |
27537 | 542 export def FTprogress_cweb() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
543 if exists("g:filetype_w") |
27537 | 544 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
|
545 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
546 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
547 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
|
548 setf progress |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
549 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
550 setf cweb |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
551 endif |
27537 | 552 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
553 |
27537 | 554 export def FTprogress_asm() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
555 if exists("g:filetype_i") |
27537 | 556 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
|
557 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
558 endif |
27537 | 559 # This function checks for an assembly comment the first ten lines. |
560 # If not found, assume Progress. | |
561 var lnum = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
562 while lnum <= 10 && lnum < line('$') |
27537 | 563 var line = getline(lnum) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
564 if line =~ '^\s*;' || line =~ '^\*' |
27537 | 565 FTasm() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
566 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
567 elseif line !~ '^\s*$' || line =~ '^/\*' |
27537 | 568 # Not an empty line: Doesn't look like valid assembly code. |
569 # 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
|
570 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
571 endif |
27537 | 572 lnum += 1 |
27972
9c0b7953016e
patch 8.2.4511: filetype test fails
Bram Moolenaar <Bram@vim.org>
parents:
27903
diff
changeset
|
573 endwhile |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
574 setf progress |
27537 | 575 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
576 |
27537 | 577 var ft_pascal_comments = '^\s*\%({\|(\*\|//\)' |
578 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
|
579 |
27537 | 580 export def FTprogress_pascal() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
581 if exists("g:filetype_p") |
27537 | 582 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
|
583 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
584 endif |
27537 | 585 # This function checks for valid Pascal syntax in the first ten lines. |
586 # Look for either an opening comment or a program start. | |
587 # If not found, assume Progress. | |
588 var lnum = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
589 while lnum <= 10 && lnum < line('$') |
27537 | 590 var line = getline(lnum) |
27845
e63514ae0c29
patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents:
27557
diff
changeset
|
591 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
|
592 setf pascal |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
593 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
594 elseif line !~ '^\s*$' || line =~ '^/\*' |
27537 | 595 # Not an empty line: Doesn't look like valid Pascal code. |
596 # 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
|
597 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
598 endif |
27537 | 599 lnum += 1 |
27972
9c0b7953016e
patch 8.2.4511: filetype test fails
Bram Moolenaar <Bram@vim.org>
parents:
27903
diff
changeset
|
600 endwhile |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
601 setf progress |
27537 | 602 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
603 |
27537 | 604 export def FTpp() |
23584
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
605 if exists("g:filetype_pp") |
27537 | 606 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
|
607 else |
27537 | 608 var line = getline(nextnonblank(1)) |
27845
e63514ae0c29
patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents:
27557
diff
changeset
|
609 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
|
610 setf pascal |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
611 else |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
612 setf puppet |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
613 endif |
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
614 endif |
27537 | 615 enddef |
23584
397f95f103e8
patch 8.2.2334: Pascal-like filetypes not always detected
Bram Moolenaar <Bram@vim.org>
parents:
21991
diff
changeset
|
616 |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
617 # 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
|
618 export def FTprg() |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
619 if exists("g:filetype_prg") |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
620 exe "setf " .. g:filetype_prg |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
621 elseif IsRapid() |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
622 setf rapid |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
623 else |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
624 # Nothing recognized, assume Clipper |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
625 setf clipper |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
626 endif |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
627 enddef |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
628 |
27537 | 629 export def FTr() |
630 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
|
631 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
632 for n in range(1, max) |
27537 | 633 # 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
|
634 if getline(n) =~? '\<REBOL\>' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
635 setf rebol |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
636 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
637 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
638 endfor |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
639 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
640 for n in range(1, max) |
27537 | 641 # R has # comments |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
642 if getline(n) =~ '^\s*#' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
643 setf r |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
644 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
645 endif |
27537 | 646 # Rexx has /* comments */ |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
647 if getline(n) =~ '^\s*/\*' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
648 setf rexx |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
649 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
650 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
651 endfor |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
652 |
27537 | 653 # 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
|
654 if exists("g:filetype_r") |
27537 | 655 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
|
656 else |
27537 | 657 # 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
|
658 setf r |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
659 endif |
27537 | 660 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
661 |
27537 | 662 export def McSetf() |
663 # Rely on the file to start with a comment. | |
664 # 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
|
665 for lnum in range(1, min([line("$"), 20])) |
27537 | 666 var line = getline(lnum) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
667 if line =~ '^\s*\(#\|dnl\)' |
27537 | 668 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
|
669 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
670 elseif line =~ '^\s*;' |
27537 | 671 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
|
672 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
673 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
674 endfor |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
675 setf m4 # Default: Sendmail .mc file |
27537 | 676 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
677 |
27537 | 678 # Called from filetype.vim and scripts.vim. |
679 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
|
680 if did_filetype() |
27537 | 681 # 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
|
682 return |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
683 endif |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
684 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
|
685 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
686 endif |
27537 | 687 if name =~ '\<csh\>' |
688 # Some .sh scripts contain #!/bin/csh. | |
689 SetFileTypeShell("csh") | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
690 return |
27537 | 691 elseif name =~ '\<tcsh\>' |
692 # Some .sh scripts contain #!/bin/tcsh. | |
693 SetFileTypeShell("tcsh") | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
694 return |
27537 | 695 elseif name =~ '\<zsh\>' |
696 # Some .sh scripts contain #!/bin/zsh. | |
697 SetFileTypeShell("zsh") | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
698 return |
27537 | 699 elseif name =~ '\<ksh\>' |
700 b:is_kornshell = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
701 if exists("b:is_bash") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
702 unlet b:is_bash |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
703 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
704 if exists("b:is_sh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
705 unlet b:is_sh |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
706 endif |
27537 | 707 elseif exists("g:bash_is_sh") || name =~ '\<bash\>' || name =~ '\<bash2\>' |
708 b:is_bash = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
709 if exists("b:is_kornshell") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
710 unlet b:is_kornshell |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
711 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
712 if exists("b:is_sh") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
713 unlet b:is_sh |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
714 endif |
27537 | 715 elseif name =~ '\<sh\>' |
716 b:is_sh = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
717 if exists("b:is_kornshell") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
718 unlet b:is_kornshell |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
719 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
720 if exists("b:is_bash") |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
721 unlet b:is_bash |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
722 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
723 endif |
27537 | 724 SetFileTypeShell("sh") |
725 enddef | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
726 |
27537 | 727 # For shell-like file types, check for an "exec" command hidden in a comment, |
728 # as used for Tcl. | |
729 # Also called from scripts.vim, thus can't be local to this script. | |
730 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
|
731 if did_filetype() |
27537 | 732 # 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
|
733 return |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
734 endif |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
735 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
|
736 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
737 endif |
27537 | 738 var l = 2 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
739 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' |
27537 | 740 # Skip empty and comment lines. |
741 l += 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
742 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
743 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' |
27537 | 744 # Found an "exec" line after a comment with continuation |
745 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
|
746 if n =~ '\<tclsh\|\<wish' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
747 setf tcl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
748 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
749 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
750 endif |
27537 | 751 exe "setf " .. name |
752 enddef | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
753 |
27537 | 754 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
|
755 if did_filetype() |
27537 | 756 # 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
|
757 return |
963dd629d19a
patch 8.1.0771: some shell filetype patterns end in a star
Bram Moolenaar <Bram@vim.org>
parents:
14999
diff
changeset
|
758 endif |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
759 if exists("g:filetype_csh") |
27537 | 760 SetFileTypeShell(g:filetype_csh) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
761 elseif &shell =~ "tcsh" |
27537 | 762 SetFileTypeShell("tcsh") |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
763 else |
27537 | 764 SetFileTypeShell("csh") |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
765 endif |
27537 | 766 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
767 |
27537 | 768 var ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' |
769 export def FTRules() | |
770 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
|
771 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
|
772 setf udevrules |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
773 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
774 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
775 if path =~ '^/etc/ufw/' |
27537 | 776 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
|
777 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
778 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
779 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
|
780 setf javascript |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
781 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
782 endif |
27537 | 783 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
|
784 try |
27537 | 785 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
|
786 catch /^Vim\%((\a\+)\)\=:E484/ |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
787 setf hog |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
788 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
789 endtry |
27537 | 790 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
|
791 for line in config_lines |
27845
e63514ae0c29
patch 8.2.4448: filetype detection is failing
Bram Moolenaar <Bram@vim.org>
parents:
27557
diff
changeset
|
792 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
|
793 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
|
794 if dir == udev_rules |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
795 setf udevrules |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
796 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
797 break |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
798 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
799 endfor |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
800 setf hog |
27537 | 801 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
802 |
27537 | 803 export def SQL() |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
804 if exists("g:filetype_sql") |
27537 | 805 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
|
806 else |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
807 setf sql |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
808 endif |
27537 | 809 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
810 |
28443
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
811 # 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
|
812 # detection between scala and SuperCollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
813 export def FTsc() |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
814 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
|
815 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
|
816 setf supercollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
817 return |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
818 endif |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
819 endfor |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
820 setf scala |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
821 enddef |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
822 |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
823 # 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
|
824 # detection between scdoc and SuperCollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
825 export def FTscd() |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
826 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
|
827 setf scdoc |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
828 else |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
829 setf supercollider |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
830 endif |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
831 enddef |
5896c0f6cdd7
patch 8.2.4746: supercollider filetype not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28390
diff
changeset
|
832 |
27537 | 833 # If the file has an extension of 't' and is in a directory 't' or 'xt' then |
834 # it is almost certainly a Perl test file. | |
835 # If the first line starts with '#' and contains 'perl' it's probably a Perl | |
836 # file. | |
837 # (Slow test) If a file contains a 'use' statement then it is almost certainly | |
838 # a Perl file. | |
839 export def FTperl(): number | |
840 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
|
841 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
|
842 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
843 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
844 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
845 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
|
846 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
847 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
848 endif |
27537 | 849 var save_cursor = getpos('.') |
850 call cursor(1, 1) | |
27557
ce72087b601f
patch 8.2.4305: tex filetype detection fails
Bram Moolenaar <Bram@vim.org>
parents:
27538
diff
changeset
|
851 var has_use = search('^use\s\s*\k', 'c', 30) > 0 |
13051 | 852 call setpos('.', save_cursor) |
853 if has_use | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
854 setf perl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
855 return 1 |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
856 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
857 return 0 |
27537 | 858 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
859 |
29338
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
860 # LambdaProlog and Standard ML signature files |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
861 export def FTsig() |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
862 if exists("g:filetype_sig") |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
863 exe "setf " .. g:filetype_sig |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
864 return |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
865 endif |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
866 |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
867 var lprolog_comment = '^\s*\%(/\*\|%\)' |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
868 var lprolog_keyword = '^\s*sig\s\+\a' |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
869 var sml_comment = '^\s*(\*' |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
870 var sml_keyword = '^\s*\%(signature\|structure\)\s\+\a' |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
871 |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
872 var line = getline(nextnonblank(1)) |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
873 |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
874 if line =~ lprolog_comment || line =~# lprolog_keyword |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
875 setf lprolog |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
876 elseif line =~ sml_comment || line =~# sml_keyword |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
877 setf sml |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
878 endif |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
879 enddef |
f4f531986753
patch 9.0.0012: signature files not detected properly
Bram Moolenaar <Bram@vim.org>
parents:
29326
diff
changeset
|
880 |
30023
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
881 # This function checks the first 100 lines of files matching "*.sil" to |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
882 # resolve detection between Swift Intermediate Language and SILE. |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
883 export def FTsil() |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
884 for lnum in range(1, [line('$'), 100]->min()) |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
885 var line: string = getline(lnum) |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
886 if line =~ '^\s*[\\%]' |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
887 setf sile |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
888 return |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
889 elseif line =~ '^\s*\S' |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
890 setf sil |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
891 return |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
892 endif |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
893 endfor |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
894 # no clue, default to "sil" |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
895 setf sil |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
896 enddef |
87063bfe81cd
patch 9.0.0349: filetype of *.sil files not well detected
Bram Moolenaar <Bram@vim.org>
parents:
29659
diff
changeset
|
897 |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
898 export def FTsys() |
28445
7f0ec490d608
patch 8.2.4747: no filetype override for .sys files
Bram Moolenaar <Bram@vim.org>
parents:
28443
diff
changeset
|
899 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
|
900 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
|
901 elseif IsRapid() |
28390
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
902 setf rapid |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
903 else |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
904 setf bat |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
905 endif |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
906 enddef |
cc4d3ded4004
patch 8.2.0003: Build file dependencies are incomplete
Bram Moolenaar <Bram@vim.org>
parents:
28379
diff
changeset
|
907 |
27537 | 908 # Choose context, plaintex, or tex (LaTeX) based on these rules: |
909 # 1. Check the first line of the file for "%&<format>". | |
910 # 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. | |
911 # 3. Default to "plain" or to g:tex_flavor, can be set in user's vimrc. | |
912 export def FTtex() | |
913 var firstline = getline(1) | |
914 var format: string | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
915 if firstline =~ '^%&\s*\a\+' |
27537 | 916 format = tolower(matchstr(firstline, '\a\+')) |
917 format = substitute(format, 'pdf', '', '') | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
918 if format == 'tex' |
27537 | 919 format = 'latex' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
920 elseif format == 'plaintex' |
27537 | 921 format = 'plain' |
12816
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 elseif expand('%') =~ 'tex/context/.*/.*.tex' |
27537 | 924 format = 'context' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
925 else |
27537 | 926 # Default value, may be changed later: |
927 format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' | |
928 # Save position, go to the top of the file, find first non-comment line. | |
929 var save_cursor = getpos('.') | |
930 call cursor(1, 1) | |
931 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
|
932 if firstNC > 0 |
ce72087b601f
patch 8.2.4305: tex filetype detection fails
Bram Moolenaar <Bram@vim.org>
parents:
27538
diff
changeset
|
933 # Check the next thousand lines for a LaTeX or ConTeXt keyword. |
27537 | 934 var lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' |
935 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\>' | |
936 var kwline = search('^\s*\\\%(' .. lpat .. '\)\|^\s*\\\(' .. cpat .. '\)', | |
937 'cnp', firstNC + 1000) | |
938 if kwline == 1 # lpat matched | |
939 format = 'latex' | |
940 elseif kwline == 2 # cpat matched | |
941 format = 'context' | |
942 endif # If neither matched, keep default set above. | |
943 # let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) | |
944 # let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) | |
945 # if cline > 0 | |
946 # let format = 'context' | |
947 # endif | |
948 # if lline > 0 && (cline == 0 || cline > lline) | |
949 # let format = 'tex' | |
950 # endif | |
951 endif # firstNC | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
952 call setpos('.', save_cursor) |
27537 | 953 endif # firstline =~ '^%&\s*\a\+' |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
954 |
27537 | 955 # 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
|
956 if format == 'plain' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
957 setf plaintex |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
958 elseif format == 'context' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
959 setf context |
27537 | 960 else # probably LaTeX |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
961 setf tex |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
962 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
963 return |
27537 | 964 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
965 |
27537 | 966 export def FTxml() |
967 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
|
968 while n < 100 && n <= line("$") |
27537 | 969 var line = getline(n) |
970 # DocBook 4 or DocBook 5. | |
971 var is_docbook4 = line =~ '<!DOCTYPE.*DocBook' | |
972 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
|
973 if is_docbook4 || is_docbook5 |
27537 | 974 b:docbk_type = "xml" |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
975 if is_docbook5 |
27537 | 976 b:docbk_ver = 5 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
977 else |
27537 | 978 b:docbk_ver = 4 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
979 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
980 setf docbk |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
981 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
982 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
983 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
|
984 setf xbl |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
985 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
986 endif |
27537 | 987 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
988 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
989 setf xml |
27537 | 990 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
991 |
27537 | 992 export def FTy() |
993 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
|
994 while n < 100 && n <= line("$") |
27537 | 995 var line = getline(n) |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
996 if line =~ '^\s*%' |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
997 setf yacc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
998 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
999 endif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1000 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
|
1001 setf racc |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1002 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1003 endif |
27537 | 1004 n += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1005 endwhile |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1006 setf yacc |
27537 | 1007 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1008 |
27537 | 1009 export def Redif() |
1010 var lnum = 1 | |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1011 while lnum <= 5 && lnum < line('$') |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1012 if getline(lnum) =~ "^\ctemplate-type:" |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1013 setf redif |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1014 return |
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1015 endif |
27537 | 1016 lnum += 1 |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1017 endwhile |
27537 | 1018 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1019 |
27537 | 1020 # This function is called for all files under */debian/patches/*, make sure not |
1021 # to non-dep3patch files, such as README and other text files. | |
1022 export def Dep3patch() | |
26628
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1023 if expand('%:t') ==# 'series' |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1024 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1025 endif |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1026 |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1027 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
|
1028 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
|
1029 setf dep3patch |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1030 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1031 elseif ln =~# '^---' |
27537 | 1032 # 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
|
1033 return |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1034 endif |
7efd8f561d04
patch 8.2.3843: dep3patch files are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
26438
diff
changeset
|
1035 endfor |
27537 | 1036 enddef |
12816
218102da5226
patch 8.0.1285: occasional crash when using a channel
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1037 |
27537 | 1038 # This function checks the first 15 lines for appearance of 'FoamFile' |
1039 # and then 'object' in a following line. | |
1040 # In that case, it's probably an OpenFOAM file | |
1041 export def FTfoam() | |
1042 var ffile = 0 | |
1043 var lnum = 1 | |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
1044 while lnum <= 15 |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
1045 if getline(lnum) =~# '^FoamFile' |
27537 | 1046 ffile = 1 |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
1047 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
|
1048 setf foam |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
1049 return |
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
1050 endif |
27537 | 1051 lnum += 1 |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
1052 endwhile |
27537 | 1053 enddef |
27070
b353bd9faec8
patch 8.2.4064: foam files are not detected
Bram Moolenaar <Bram@vim.org>
parents:
26708
diff
changeset
|
1054 |
27537 | 1055 # Determine if a *.tf file is TF mud client or terraform |
1056 export def FTtf() | |
1057 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
|
1058 for i in range(1, numberOfLines) |
27537 | 1059 var currentLine = trim(getline(i)) |
1060 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
|
1061 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
|
1062 setf terraform |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
1063 return |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
1064 endif |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
1065 endfor |
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
1066 setf tf |
27537 | 1067 enddef |
27420
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
1068 |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
1069 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
|
1070 # 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
|
1071 export def FTsrc() |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
1072 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
|
1073 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
|
1074 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
|
1075 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
|
1076 setf krl |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1077 endif |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1078 enddef |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1079 |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1080 # 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
|
1081 export def FTdat() |
28483
62a0dd56466c
patch 8.2.4766: KRL files using "deffct" not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28445
diff
changeset
|
1082 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
|
1083 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
|
1084 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
|
1085 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
|
1086 setf krl |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1087 endif |
1aa3460f799d
patch 8.2.4701: Kuka Robot Language files not recognized
Bram Moolenaar <Bram@vim.org>
parents:
28010
diff
changeset
|
1088 enddef |
27420
978890380129
patch 8.2.4238: *.tf file could be fileytpe "tf" or "terraform"
Bram Moolenaar <Bram@vim.org>
parents:
27287
diff
changeset
|
1089 |
30890
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1090 export def FTlsl() |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1091 if exists("g:filetype_lsl") |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1092 exe "setf " .. g:filetype_lsl |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1093 endif |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1094 |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1095 var line = getline(nextnonblank(1)) |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1096 if line =~ '^\s*%' || line =~# ':\s*trait\s*$' |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1097 setf larch |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1098 else |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1099 setf lsl |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1100 endif |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1101 enddef |
ebcaf6bbb410
patch 9.0.0779: lsl and lm3 file extensions are not recognized
Bram Moolenaar <Bram@vim.org>
parents:
30873
diff
changeset
|
1102 |
27537 | 1103 # 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
|
1104 # defcompile |