comparison runtime/autoload/dist/ft.vim @ 29326:1f1d99bba06c v9.0.0006

patch 9.0.0006: not all Visual Basic files are recognized Commit: https://github.com/vim/vim/commit/8b5901e2f9466eb6f38f5b251e871f609f65e252 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 29 14:39:12 2022 +0100 patch 9.0.0006: not all Visual Basic files are recognized Problem: Not all Visual Basic files are recognized. Solution: Change detection of *.cls files. (Doug Kearns)
author Bram Moolenaar <Bram@vim.org>
date Wed, 29 Jun 2022 15:45:03 +0200
parents f73a9bdff3a3
children f4f531986753
comparison
equal deleted inserted replaced
29325:ef612068880a 29326:1f1d99bba06c
70 return 70 return
71 endif 71 endif
72 72
73 # most frequent FreeBASIC-specific keywords in distro files 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*[:=(]\)\@!' 74 var fb_keywords = '\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!'
75 var fb_preproc = '\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)' 75 var fb_preproc = '\c^\s*\%(' ..
76 # preprocessor
77 '#\s*\a\+\|' ..
78 # compiler option
79 'option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\|' ..
80 # metacommand
81 '\%(''\|rem\)\s*\$lang\>\|' ..
82 # default datatype
83 'def\%(byte\|longint\|short\|ubyte\|uint\|ulongint\|ushort\)\>' ..
84 '\)'
76 var fb_comment = "^\\s*/'" 85 var fb_comment = "^\\s*/'"
86
77 # OPTION EXPLICIT, without the leading underscore, is common to many dialects 87 # OPTION EXPLICIT, without the leading underscore, is common to many dialects
78 var qb64_preproc = '\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)' 88 var qb64_preproc = '\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)'
79 89
80 var lines = getline(1, min([line("$"), 100])) 90 for lnum in range(1, min([line("$"), 100]))
81 91 var line = getline(lnum)
82 if match(lines, fb_preproc) > -1 || match(lines, fb_comment) > -1 || match(lines, fb_keywords) > -1 92 if line =~ ft_visual_basic_content
83 setf freebasic 93 setf vb
84 elseif match(lines, qb64_preproc) > -1 94 return
85 setf qb64 95 elseif line =~ fb_preproc || line =~ fb_comment || line =~ fb_keywords
86 elseif match(lines, ft_visual_basic_content) > -1 96 setf freebasic
87 setf vb 97 return
88 else 98 elseif line =~ qb64_preproc
89 setf basic 99 setf qb64
90 endif 100 return
101 endif
102 endfor
103 setf basic
91 enddef 104 enddef
92 105
93 export def FTbtm() 106 export def FTbtm()
94 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm 107 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
95 setf dosbatch 108 setf dosbatch
121 exe "setf " .. g:filetype_cfg 134 exe "setf " .. g:filetype_cfg
122 elseif IsRapid("cfg") 135 elseif IsRapid("cfg")
123 setf rapid 136 setf rapid
124 else 137 else
125 setf cfg 138 setf cfg
139 endif
140 enddef
141
142 export def FTcls()
143 if exists("g:filetype_cls")
144 exe "setf " .. g:filetype_cls
145 return
146 endif
147
148 if getline(1) =~ '^%'
149 setf tex
150 elseif getline(1)[0] == '#' && getline(1) =~ 'rexx'
151 setf rexx
152 elseif getline(1) == 'VERSION 1.0 CLASS'
153 setf vb
154 else
155 setf st
126 endif 156 endif
127 enddef 157 enddef
128 158
129 export def FTlpc() 159 export def FTlpc()
130 if exists("g:lpc_syntax_for_c") 160 if exists("g:lpc_syntax_for_c")