# Vim functions for file type detection
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
-# Last Change: 2026 Feb 24
+# Last Change: 2026 Mar 13
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
# These functions are moved here from runtime/filetype.vim to make startup
endif
enddef
+# Determines whether a *.cls file is ObjectScript, TeX, Rexx, Visual Basic, or Smalltalk.
export def FTcls()
if exists("g:filetype_cls")
exe "setf " .. g:filetype_cls
endif
var nonblank1 = getline(nextnonblank(1))
- if nonblank1 =~ '^\v%(\%|\\)'
+ var lnum = nextnonblank(1)
+ while lnum > 0 && lnum <= line("$")
+ var line = getline(lnum)
+ if line =~? '^\s*\%(import\|include\|includegenerator\)\>'
+ lnum = nextnonblank(lnum + 1)
+ else
+ nonblank1 = line
+ break
+ endif
+ endwhile
+
+ if nonblank1 =~? '^\s*class\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s\+extends\>\|\s*\[\|\s*{\|$\)'
+ setf objectscript
+ elseif nonblank1 =~ '^\v%(\%|\\)'
setf tex
elseif nonblank1 =~ '^\s*\%(/\*\|::\w\)'
setf rexx
" SiSU
au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
-" Smalltalk (and Rexx, TeX, and Visual Basic)
+" Smalltalk (and ObjectScript, Rexx, TeX, and Visual Basic)
au BufNewFile,BufRead *.cls call dist#ft#FTcls()
" SMIL or XML
bwipe!
unlet g:filetype_cls
+ let g:filetype_cls = 'objectscript'
+ split Xfile.cls
+ call assert_equal('objectscript', &filetype)
+ bwipe!
+ unlet g:filetype_cls
+
+ " ObjectScript
+
+ call writefile(['Class User.Person Extends (%Persistent, %Populate)'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('objectscript', &filetype)
+ bwipe!
+
+ call writefile(['Import MyApp.Utils', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('objectscript', &filetype)
+ bwipe!
+
+ call writefile(['Include MyMacros', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('objectscript', &filetype)
+ bwipe!
+
+ call writefile(['IncludeGenerator MyGen', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('objectscript', &filetype)
+ bwipe!
+
+ call writefile(['Import MyApp.Utils', 'Include MyMacros', 'IncludeGenerator MyGen', 'Class User.Person Extends %Persistent'], 'Xfile.cls')
+ split Xfile.cls
+ call assert_equal('objectscript', &filetype)
+ bwipe!
+
" TeX
call writefile(['%'], 'Xfile.cls')
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 155,
/**/
154,
/**/