patch 9.2.0237: filetype: ObjectScript routines are not recognized

Problem:  filetype: ObjectScript routines are not recognized
Solution: Add ObjectScript routines detection for .mac, .int, and .inc
          files (Hannah Kimura)

Reference:
https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GORIENT_ch_intro#GORIENT_intro_routines

closes: #19805

Signed-off-by: Hannah Kimura <hannah.kimura@intersystems.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Hannah Kimura
2026-03-24 19:58:01 +00:00
committed by Christian Brabandt
parent a603175c6c
commit 25f6539645
5 changed files with 100 additions and 4 deletions
+33 -1
View File
@@ -3,7 +3,7 @@ vim9script
# Vim functions for file type detection
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
# Last Change: 2026 Mar 20
# Last Change: 2026 Mar 24
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
# These functions are moved here from runtime/filetype.vim to make startup
@@ -11,6 +11,12 @@ vim9script
var prolog_pattern = '^\s*\(:-\|%\+\(\s\|$\)\|\/\*\)\|\.\s*$'
def IsObjectScriptRoutine(): bool
var line1 = getline(1)
line1 = substitute(line1, '^\ufeff', '', '')
return line1 =~? '^\s*routine\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s*\[\|\s*;\|$\)'
enddef
export def Check_inp()
if getline(1) =~ '%%'
setf tex
@@ -75,6 +81,18 @@ export def FTasm()
exe "setf " .. fnameescape(b:asmsyntax)
enddef
export def FTmac()
if exists("g:filetype_mac")
exe "setf " .. g:filetype_mac
else
if IsObjectScriptRoutine()
setf objectscript_routine
else
FTasm()
endif
endif
enddef
export def FTasmsyntax()
# see if the file contains any asmsyntax=foo overrides. If so, change
# b:asmsyntax appropriately
@@ -871,6 +889,10 @@ export def FTinc()
if exists("g:filetype_inc")
exe "setf " .. g:filetype_inc
else
if IsObjectScriptRoutine()
setf objectscript_routine
return
endif
for lnum in range(1, min([line("$"), 20]))
var line = getline(lnum)
if line =~? "perlscript"
@@ -940,6 +962,16 @@ export def FTi()
setf progress
enddef
export def FTint()
if exists("g:filetype_int")
exe "setf " .. g:filetype_int
elseif IsObjectScriptRoutine()
setf objectscript_routine
else
setf hex
endif
enddef
var ft_pascal_comments = '^\s*\%({\|(\*\|//\)'
var ft_pascal_keywords = '^\s*\%(program\|unit\|library\|uses\|begin\|procedure\|function\|const\|type\|var\)\>'
+3 -1
View File
@@ -1,4 +1,4 @@
*filetype.txt* For Vim version 9.2. Last change: 2026 Feb 14
*filetype.txt* For Vim version 9.2. Last change: 2026 Mar 24
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -161,8 +161,10 @@ variables can be used to overrule the filetype used for certain extensions:
|ft-cpp-syntax|
*.i g:filetype_i |ft-progress-syntax|
*.inc g:filetype_inc
*.int g:filetype_int
*.lsl g:filetype_lsl
*.m g:filetype_m |ft-mathematica-syntax|
*.mac g:filetype_mac
*[mM]makefile,*.mk,*.mak,[mM]akefile*
g:make_flavor |ft-make-syntax|
*.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md
+8 -2
View File
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: The Vim Project <https://github.com/vim/vim>
" Last Change: 2026 Mar 23
" Last Change: 2026 Mar 24
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
" If the filetype can be detected from extension or file name(the final path component),
@@ -119,10 +119,13 @@ au BufNewFile,BufRead */boot/grub/menu.lst,*/boot/grub/grub.conf,*/etc/grub.conf
" *.mc omitted - used by dist#ft#McSetf()
au BufNewFile,BufRead *.demo,*.dm{1,2,3,t},*.wxm,maxima-init.mac setf maxima
" ObjectScript routine or assembly
au BufNewFile,BufRead *.mac call dist#ft#FTmac()
" Assembly (all kinds)
" *.lst is not pure assembly, it has two extra columns (address, byte codes)
" *.[sS], *.[aA] usually Assembly - GNU
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call dist#ft#FTasm()
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.lst call dist#ft#FTasm()
" BASIC or Visual Basic
au BufNewFile,BufRead *.bas call dist#ft#FTbas()
@@ -572,6 +575,9 @@ au BufNewFile,BufRead *.pro call dist#ft#ProtoCheck('idlang')
" Initng
au BufNewFile,BufRead */etc/initng/*/*.i,*.ii setf initng
" Intel HEX or ObjectScript routine
au BufNewFile,BufRead *.int call dist#ft#FTint()
" Innovation Data Processing
au BufNewFile,BufRead upstream.dat\c,upstream.*.dat\c,*.upstream.dat\c setf upstreamdat
au BufNewFile,BufRead fdrupstream.log,upstream.log\c,upstream.*.log\c,*.upstream.log\c,UPSTREAM-*.log\c setf upstreamlog
+54
View File
@@ -2779,6 +2779,12 @@ func Test_inc_file()
call assert_equal('pov', &filetype)
bwipe!
" ObjectScript routine
call writefile(['ROUTINE Sample [Type=INC]'], 'Xfile.inc', 'D')
split Xfile.inc
call assert_equal('objectscript_routine', &filetype)
bwipe!
let g:filetype_inc = 'foo'
split Xfile.inc
call assert_equal('foo', &filetype)
@@ -2864,6 +2870,54 @@ func Test_inc_file()
filetype off
endfunc
func Test_int_file()
filetype on
" Intel HEX
call writefile([':10010000214601360121470136007EFE09D2190140'], 'Xfile.int', 'D')
split Xfile.int
call assert_equal('hex', &filetype)
bwipe!
" ObjectScript routine
call writefile(['ROUTINE Sample [Type=INT]'], 'Xfile.int', 'D')
split Xfile.int
call assert_equal('objectscript_routine', &filetype)
bwipe!
let g:filetype_int = 'foo'
split Xfile.int
call assert_equal('foo', &filetype)
bwipe!
unlet g:filetype_int
filetype off
endfunc
func Test_mac_file()
filetype on
" Assembly
call writefile(['looks like asm'], 'Xfile.mac', 'D')
split Xfile.mac
call assert_equal('asm', &filetype)
bwipe!
" ObjectScript routine
call writefile(['ROUTINE Sample [Type=MAC]'], 'Xfile.mac', 'D')
split Xfile.mac
call assert_equal('objectscript_routine', &filetype)
bwipe!
let g:filetype_mac = 'foo'
split Xfile.mac
call assert_equal('foo', &filetype)
bwipe!
unlet g:filetype_mac
filetype off
endfunc
func Test_ll_file()
filetype on
+2
View File
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
237,
/**/
236,
/**/