From: Hannah Kimura Date: Tue, 24 Mar 2026 19:58:01 +0000 (+0000) Subject: patch 9.2.0237: filetype: ObjectScript routines are not recognized X-Git-Tag: v9.2.0237^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25f6539645d805295b11253c7bd8632aa20604f4;p=thirdparty%2Fvim.git 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 Signed-off-by: Christian Brabandt --- diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 5b54b1c47b..20495866b3 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 -# Last Change: 2026 Mar 20 +# Last Change: 2026 Mar 24 # Former Maintainer: Bram Moolenaar # 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\)\>' diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index 8dbe4e68c0..6a7fa3b590 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -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 diff --git a/runtime/filetype.vim b/runtime/filetype.vim index a63efb2431..aa36477c1d 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -1,7 +1,7 @@ " Vim support file to detect file types " " Maintainer: The Vim Project -" Last Change: 2026 Mar 23 +" Last Change: 2026 Mar 24 " Former Maintainer: Bram Moolenaar " 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 diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 056d2fe1b7..e24471b6f2 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -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 diff --git a/src/version.c b/src/version.c index 80680b4264..412a37bb0c 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 */ +/**/ + 237, /**/ 236, /**/