# 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
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
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
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"
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\)\>'
-*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
|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
" 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),
" *.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()
" 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
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)
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 237,
/**/
236,
/**/