]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0237: filetype: ObjectScript routines are not recognized v9.2.0237
authorHannah Kimura <hannah.kimura@intersystems.com>
Tue, 24 Mar 2026 19:58:01 +0000 (19:58 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 24 Mar 2026 19:58:01 +0000 (19:58 +0000)
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>
runtime/autoload/dist/ft.vim
runtime/doc/filetype.txt
runtime/filetype.vim
src/testdir/test_filetype.vim
src/version.c

index 5b54b1c47bb3d7f21bd319eb4cd1822f5b63ae99..20495866b3d23977e3bd00267e1c2a6fe351e098 100644 (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\)\>'
 
index 8dbe4e68c0049bc3e80a1d6ba27cb7d965ddaa47..6a7fa3b5905ab2d5307a40aab106bb3aa26431d8 100644 (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
index a63efb24311f320eb58f3846300ef65cc8e9e4fb..aa36477c1d17b0bf37429d9e3683f004ecbcd6a3 100644 (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
index 056d2fe1b794ce00f824cce4e7683945935ff7be..e24471b6f273b441400ee3037f27ef813b1cc130 100644 (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
 
index 80680b4264a79684d5f1b025b887054b09251587..412a37bb0c9a5370ae35873e0d38b4f4bebc4ac3 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    237,
 /**/
     236,
 /**/