Skip to content

Commit 25f6539

Browse files
hkimura-intersyschrisbra
authored andcommitted
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>
1 parent a603175 commit 25f6539

5 files changed

Lines changed: 100 additions & 4 deletions

File tree

runtime/autoload/dist/ft.vim

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ vim9script
33
# Vim functions for file type detection
44
#
55
# Maintainer: The Vim Project <https://github.com/vim/vim>
6-
# Last Change: 2026 Mar 20
6+
# Last Change: 2026 Mar 24
77
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
88

99
# These functions are moved here from runtime/filetype.vim to make startup
1010
# faster.
1111

1212
var prolog_pattern = '^\s*\(:-\|%\+\(\s\|$\)\|\/\*\)\|\.\s*$'
1313

14+
def IsObjectScriptRoutine(): bool
15+
var line1 = getline(1)
16+
line1 = substitute(line1, '^\ufeff', '', '')
17+
return line1 =~? '^\s*routine\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s*\[\|\s*;\|$\)'
18+
enddef
19+
1420
export def Check_inp()
1521
if getline(1) =~ '%%'
1622
setf tex
@@ -75,6 +81,18 @@ export def FTasm()
7581
exe "setf " .. fnameescape(b:asmsyntax)
7682
enddef
7783

84+
export def FTmac()
85+
if exists("g:filetype_mac")
86+
exe "setf " .. g:filetype_mac
87+
else
88+
if IsObjectScriptRoutine()
89+
setf objectscript_routine
90+
else
91+
FTasm()
92+
endif
93+
endif
94+
enddef
95+
7896
export def FTasmsyntax()
7997
# see if the file contains any asmsyntax=foo overrides. If so, change
8098
# b:asmsyntax appropriately
@@ -871,6 +889,10 @@ export def FTinc()
871889
if exists("g:filetype_inc")
872890
exe "setf " .. g:filetype_inc
873891
else
892+
if IsObjectScriptRoutine()
893+
setf objectscript_routine
894+
return
895+
endif
874896
for lnum in range(1, min([line("$"), 20]))
875897
var line = getline(lnum)
876898
if line =~? "perlscript"
@@ -940,6 +962,16 @@ export def FTi()
940962
setf progress
941963
enddef
942964

965+
export def FTint()
966+
if exists("g:filetype_int")
967+
exe "setf " .. g:filetype_int
968+
elseif IsObjectScriptRoutine()
969+
setf objectscript_routine
970+
else
971+
setf hex
972+
endif
973+
enddef
974+
943975
var ft_pascal_comments = '^\s*\%({\|(\*\|//\)'
944976
var ft_pascal_keywords = '^\s*\%(program\|unit\|library\|uses\|begin\|procedure\|function\|const\|type\|var\)\>'
945977

runtime/doc/filetype.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*filetype.txt* For Vim version 9.2. Last change: 2026 Feb 14
1+
*filetype.txt* For Vim version 9.2. Last change: 2026 Mar 24
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -161,8 +161,10 @@ variables can be used to overrule the filetype used for certain extensions:
161161
|ft-cpp-syntax|
162162
*.i g:filetype_i |ft-progress-syntax|
163163
*.inc g:filetype_inc
164+
*.int g:filetype_int
164165
*.lsl g:filetype_lsl
165166
*.m g:filetype_m |ft-mathematica-syntax|
167+
*.mac g:filetype_mac
166168
*[mM]makefile,*.mk,*.mak,[mM]akefile*
167169
g:make_flavor |ft-make-syntax|
168170
*.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md

runtime/filetype.vim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim support file to detect file types
22
"
33
" Maintainer: The Vim Project <https://github.com/vim/vim>
4-
" Last Change: 2026 Mar 23
4+
" Last Change: 2026 Mar 24
55
" Former Maintainer: Bram Moolenaar <Bram@vim.org>
66

77
" 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
119119
" *.mc omitted - used by dist#ft#McSetf()
120120
au BufNewFile,BufRead *.demo,*.dm{1,2,3,t},*.wxm,maxima-init.mac setf maxima
121121

122+
" ObjectScript routine or assembly
123+
au BufNewFile,BufRead *.mac call dist#ft#FTmac()
124+
122125
" Assembly (all kinds)
123126
" *.lst is not pure assembly, it has two extra columns (address, byte codes)
124127
" *.[sS], *.[aA] usually Assembly - GNU
125-
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call dist#ft#FTasm()
128+
au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.lst call dist#ft#FTasm()
126129

127130
" BASIC or Visual Basic
128131
au BufNewFile,BufRead *.bas call dist#ft#FTbas()
@@ -572,6 +575,9 @@ au BufNewFile,BufRead *.pro call dist#ft#ProtoCheck('idlang')
572575
" Initng
573576
au BufNewFile,BufRead */etc/initng/*/*.i,*.ii setf initng
574577

578+
" Intel HEX or ObjectScript routine
579+
au BufNewFile,BufRead *.int call dist#ft#FTint()
580+
575581
" Innovation Data Processing
576582
au BufNewFile,BufRead upstream.dat\c,upstream.*.dat\c,*.upstream.dat\c setf upstreamdat
577583
au BufNewFile,BufRead fdrupstream.log,upstream.log\c,upstream.*.log\c,*.upstream.log\c,UPSTREAM-*.log\c setf upstreamlog

src/testdir/test_filetype.vim

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,6 +2779,12 @@ func Test_inc_file()
27792779
call assert_equal('pov', &filetype)
27802780
bwipe!
27812781

2782+
" ObjectScript routine
2783+
call writefile(['ROUTINE Sample [Type=INC]'], 'Xfile.inc', 'D')
2784+
split Xfile.inc
2785+
call assert_equal('objectscript_routine', &filetype)
2786+
bwipe!
2787+
27822788
let g:filetype_inc = 'foo'
27832789
split Xfile.inc
27842790
call assert_equal('foo', &filetype)
@@ -2864,6 +2870,54 @@ func Test_inc_file()
28642870
filetype off
28652871
endfunc
28662872

2873+
func Test_int_file()
2874+
filetype on
2875+
2876+
" Intel HEX
2877+
call writefile([':10010000214601360121470136007EFE09D2190140'], 'Xfile.int', 'D')
2878+
split Xfile.int
2879+
call assert_equal('hex', &filetype)
2880+
bwipe!
2881+
2882+
" ObjectScript routine
2883+
call writefile(['ROUTINE Sample [Type=INT]'], 'Xfile.int', 'D')
2884+
split Xfile.int
2885+
call assert_equal('objectscript_routine', &filetype)
2886+
bwipe!
2887+
2888+
let g:filetype_int = 'foo'
2889+
split Xfile.int
2890+
call assert_equal('foo', &filetype)
2891+
bwipe!
2892+
unlet g:filetype_int
2893+
2894+
filetype off
2895+
endfunc
2896+
2897+
func Test_mac_file()
2898+
filetype on
2899+
2900+
" Assembly
2901+
call writefile(['looks like asm'], 'Xfile.mac', 'D')
2902+
split Xfile.mac
2903+
call assert_equal('asm', &filetype)
2904+
bwipe!
2905+
2906+
" ObjectScript routine
2907+
call writefile(['ROUTINE Sample [Type=MAC]'], 'Xfile.mac', 'D')
2908+
split Xfile.mac
2909+
call assert_equal('objectscript_routine', &filetype)
2910+
bwipe!
2911+
2912+
let g:filetype_mac = 'foo'
2913+
split Xfile.mac
2914+
call assert_equal('foo', &filetype)
2915+
bwipe!
2916+
unlet g:filetype_mac
2917+
2918+
filetype off
2919+
endfunc
2920+
28672921
func Test_ll_file()
28682922
filetype on
28692923

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
237,
737739
/**/
738740
236,
739741
/**/

0 commit comments

Comments
 (0)