summaryrefslogtreecommitdiffstats
path: root/runtime/autoload
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-06-29 14:39:12 +0100
committerBram Moolenaar <Bram@vim.org>2022-06-29 14:39:12 +0100
commit8b5901e2f9466eb6f38f5b251e871f609f65e252 (patch)
tree430a9eae50338cd4685c7b542b51049bd2b8da5b /runtime/autoload
parent040674129f3382822eeb7b590380efa5228124a8 (diff)
patch 9.0.0006: not all Visual Basic files are recognizedv9.0.0006
Problem: Not all Visual Basic files are recognized. Solution: Change detection of *.cls files. (Doug Kearns)
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/dist/ft.vim54
1 files changed, 42 insertions, 12 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 01cde4631e..5f48f4b10d 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -72,22 +72,35 @@ export def FTbas()
# most frequent FreeBASIC-specific keywords in distro files
var fb_keywords = '\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!'
- var fb_preproc = '\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)'
+ var fb_preproc = '\c^\s*\%(' ..
+ # preprocessor
+ '#\s*\a\+\|' ..
+ # compiler option
+ 'option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\|' ..
+ # metacommand
+ '\%(''\|rem\)\s*\$lang\>\|' ..
+ # default datatype
+ 'def\%(byte\|longint\|short\|ubyte\|uint\|ulongint\|ushort\)\>' ..
+ '\)'
var fb_comment = "^\\s*/'"
+
# OPTION EXPLICIT, without the leading underscore, is common to many dialects
var qb64_preproc = '\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)'
- var lines = getline(1, min([line("$"), 100]))
-
- if match(lines, fb_preproc) > -1 || match(lines, fb_comment) > -1 || match(lines, fb_keywords) > -1
- setf freebasic
- elseif match(lines, qb64_preproc) > -1
- setf qb64
- elseif match(lines, ft_visual_basic_content) > -1
- setf vb
- else
- setf basic
- endif
+ for lnum in range(1, min([line("$"), 100]))
+ var line = getline(lnum)
+ if line =~ ft_visual_basic_content
+ setf vb
+ return
+ elseif line =~ fb_preproc || line =~ fb_comment || line =~ fb_keywords
+ setf freebasic
+ return
+ elseif line =~ qb64_preproc
+ setf qb64
+ return
+ endif
+ endfor
+ setf basic
enddef
export def FTbtm()
@@ -126,6 +139,23 @@ export def FTcfg()
endif
enddef
+export def FTcls()
+ if exists("g:filetype_cls")
+ exe "setf " .. g:filetype_cls
+ return
+ endif
+
+ if getline(1) =~ '^%'
+ setf tex
+ elseif getline(1)[0] == '#' && getline(1) =~ 'rexx'
+ setf rexx
+ elseif getline(1) == 'VERSION 1.0 CLASS'
+ setf vb
+ else
+ setf st
+ endif
+enddef
+
export def FTlpc()
if exists("g:lpc_syntax_for_c")
var lnum = 1