patch 9.2.0155: filetype: ObjectScript are not recognized
Commit:
https://github.com/vim/vim/commit/b11c8efbe6981076194e00323737780330cfd0a1
Author: Hannah <[email protected]>
Date: Fri Mar 13 21:04:26 2026 +0000
patch 9.2.0155: filetype: ObjectScript are not recognized
Problem: filetype: ObjectScript are not recognized
Solution: Add ObjectScript filetype detection for *.cls files
(Hannah Kimura)).
Reference:
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_intro
closes: #19668
Signed-off-by: Hannah <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 6cfcd350d..a90655feb 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -3,7 +3,7 @@ vim9script
# 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 <[email protected]>
# These functions are moved here from runtime/filetype.vim to make startup
@@ -195,6 +195,7 @@ export def FTcl()
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
@@ -211,7 +212,20 @@ export def FTcls()
endif
var nonblank1 = getline(nextnonblank(1))
- if nonblank1 =~ '^ %(\%|\)'
+ 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 =~ '^ %(\%|\)'
setf tex
elseif nonblank1 =~ '^\s*\%(/\*\|::\w\)'
setf rexx
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 4bdecfc7c..3031afdd6 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1054,7 +1054,7 @@ au BufNewFile,BufRead
*.scm,*.ss,*.sld,*.stsg,*/supertux2/config,.lips_repl_hist
" 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
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index 5ffc11802..125833cb9 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -2564,6 +2564,39 @@ func Test_cls_file()
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')
diff --git a/src/version.c b/src/version.c
index ae999c903..c9de55cde 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 155,
/**/
154,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1w19qZ-003wc1-E0%40256bit.org.