# Vim functions for file type detection
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
-# Last Change: 2026 Mar 24
+# Last Change: 2026 Apr 03
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
# These functions are moved here from runtime/filetype.vim to make startup
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*;\|$\)'
+ if line1 =~? '^\s*routine\>'
+ return true
+ endif
+ if line1 =~? '\<iris\>'
+ return true
+ endif
+ return join(getline(1, 3), '') =~# '%RO'
enddef
export def Check_inp()
"rst": "rst",
# RTF
"rtf": "rtf",
+ # ObjectScript Routine
+ "rtn": "objectscript_routine",
# Ruby
"rb": "ruby",
"rbw": "ruby",
numbat: ['file.nbt'],
obj: ['file.obj'],
objdump: ['file.objdump', 'file.cppobjdump'],
+ objectscript_routine: ['file.rtn'],
obse: ['file.obl', 'file.obse', 'file.oblivion', 'file.obscript'],
ocaml: ['file.ml', 'file.mli', 'file.mll', 'file.mly', '.ocamlinit', 'file.mlt', 'file.mlp', 'file.mlip', 'file.mli.cppo', 'file.ml.cppo'],
occam: ['file.occ'],
call assert_equal('objectscript_routine', &filetype)
bwipe!
+ " ObjectScript routine by IRIS marker in first line
+ call writefile(['Exported from IRIS source control'], 'Xfile.int', 'D')
+ split Xfile.int
+ call assert_equal('objectscript_routine', &filetype)
+ bwipe!
+
+ " Not ObjectScript routine by partial IRIS match in first line
+ call writefile(['Exported from IRISation source control'], 'Xfile.int', 'D')
+ split Xfile.int
+ call assert_equal('hex', &filetype)
+ bwipe!
+
+ " ObjectScript routine by %RO marker in first three lines
+ call writefile(['; generated file', '%RO routine metadata'], '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)