mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
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 <hannah.kimura@intersystems.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
e88e360a51
commit
b11c8efbe6
Vendored
+16
-2
@@ -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 <Bram@vim.org>
|
||||
|
||||
# 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 =~ '^\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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
155,
|
||||
/**/
|
||||
154,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user