[vim/vim] feat(filetype): objectscript routine detection for .rtn files (PR #19873)

12 views
Skip to first unread message

Hannah Kimura

unread,
Mar 31, 2026, 8:34:04 AM (yesterday) Mar 31
to vim/vim, Subscribed

Summary

Extends *.rtn filetype detection to recognize ObjectScript Routines.

Problem

*.rtn, files currently don't detect ObjectScript Routines.
Additionally, right now the only routines recognized are ones that have the ROUTINE header at line 1, but another allowed version (known as the compiled version) has a different header, where either Iris in in the first line or %RO is in the second line.

Solution

  • Updated runtime/filetype.vim
    • route *.rtn to dist#ft#FTrtn()
  • Updated runtime/autoload/dist/ft.vim (FTrtn()):
    • update objectscript routine (IsObjectScriptRoutine()) to also check for compiled headers in the first three lines
    • preserve existing fallback behavior
    • add overrule option for rtn : "g:filetype_rtn"

Tests

Extended src/testdir/test_filetype.vim with routine detection coverage:

  • Test_rtn_file()
    • test that it correctly matches objectscript_routine unless specifically overruled.

You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19873

Commit Summary

  • 3dfc11e feat(filetype): objectscript routine detection for .rtn files

File Changes

(4 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873@github.com>

Christian Brabandt

unread,
Mar 31, 2026, 10:50:37 AM (yesterday) Mar 31
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19873)

thanks, but objectscript_routine is a bit long. Can we shorten it? BTW, please disclose the use of AI.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/c4163229967@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 10:53:16 AM (yesterday) Mar 31
to vim/vim, Subscribed
hkimura-intersys left a comment (vim/vim#19873)

thanks, but objectscript_routine is a bit long. Can we shorten it? BTW, please disclose the use of AI.

yes, will change it.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/c4163251388@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 11:16:00 AM (yesterday) Mar 31
to vim/vim, Push

@hkimura-intersys pushed 1 commit.

  • 55c86d8 fix: shorten routine name


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/before/2cf7519a5a7690b0ea1c057233f0c42430140098/after/55c86d86a1667d02274a59f63059507de98039c2@github.com>

Christian Brabandt

unread,
Mar 31, 2026, 12:33:07 PM (yesterday) Mar 31
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#19873)

Oh, sorry, its objectscript_routine` already since v9.2.0237, so let's not change the name now.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/c4163913789@github.com>

Christian Brabandt

unread,
Mar 31, 2026, 12:33:50 PM (yesterday) Mar 31
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/autoload/dist/ft.vim:

> @@ -14,7 +14,17 @@ 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*;\|$\)'
+  if line1 =~? '^\s*routine\>\s\+[%A-Za-z][%A-Za-z0-9_.]*\%(\s*\[\|\s*;\|$\)'
+    return true
+  endif
+  if line1 =~? 'iris'
+    return true
+  endif
+  var head = getline(1, min([3, line("$")]))
+  if !empty(head)
+    head[0] = line1
+  endif
+  return join(head, "\n") =~? '%ro'

unless I am missing something, this can be simplified to:

  if line1 =~? 'iris'
    return true
  endif
  return join(getline(1, 3), '') =~ '%ro'

In runtime/autoload/dist/ft.vim:

> @@ -1057,6 +1067,15 @@ export def FTr()
   endif
 enddef
 
+export def FTrtn()
+  if exists("g:filetype_rtn")
+    exe "setf " .. g:filetype_rtn

why do we need the g:filetype_rtn variable?


In src/testdir/test_filetype.vim:

> @@ -2882,7 +2899,19 @@ func Test_int_file()
   " ObjectScript routine
   call writefile(['ROUTINE Sample [Type=INT]'], 'Xfile.int', 'D')
   split Xfile.int
-  call assert_equal('objectscript_routine', &filetype)
+  call assert_equal('iris_rtn', &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('iris_rtn', &filetype)
+  bwipe!
+
+  " ObjectScript routine by %RO marker in first three lines
+  call writefile(['; generated file', '%RO routine metadata'], 'Xfile.int', 'D')

is the %RO marker case sensitive or not?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4038604219@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 1:58:17 PM (yesterday) Mar 31
to vim/vim, Subscribed

@hkimura-intersys commented on this pull request.


In runtime/autoload/dist/ft.vim:

> @@ -1057,6 +1067,15 @@ export def FTr()
   endif
 enddef
 
+export def FTrtn()
+  if exists("g:filetype_rtn")
+    exe "setf " .. g:filetype_rtn

I thought I should add it to allow users to override rtn detection if they didn't want it to match iris_rtn


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4039106492@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 2:00:19 PM (yesterday) Mar 31
to vim/vim, Subscribed

@hkimura-intersys commented on this pull request.


In runtime/autoload/dist/ft.vim:

> @@ -1057,6 +1067,15 @@ export def FTr()
   endif
 enddef
 
+export def FTrtn()
+  if exists("g:filetype_rtn")
+    exe "setf " .. g:filetype_rtn

I can remove it if that is preferred


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4039120429@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 2:15:16 PM (yesterday) Mar 31
to vim/vim, Subscribed

@hkimura-intersys commented on this pull request.


In src/testdir/test_filetype.vim:

> @@ -2882,7 +2899,19 @@ func Test_int_file()
   " ObjectScript routine
   call writefile(['ROUTINE Sample [Type=INT]'], 'Xfile.int', 'D')
   split Xfile.int
-  call assert_equal('objectscript_routine', &filetype)
+  call assert_equal('iris_rtn', &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('iris_rtn', &filetype)
+  bwipe!
+
+  " ObjectScript routine by %RO marker in first three lines
+  call writefile(['; generated file', '%RO routine metadata'], 'Xfile.int', 'D')

its always uppercase yeah, updating regex to only match that.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4039204615@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 2:17:53 PM (yesterday) Mar 31
to vim/vim, Push

@hkimura-intersys pushed 1 commit.

  • 883d2e2 fix: update regex that matches routines


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/before/55c86d86a1667d02274a59f63059507de98039c2/after/883d2e2f4b583c0f66d81fa76e24815117aca6a1@github.com>

Christian Brabandt

unread,
Mar 31, 2026, 3:06:32 PM (yesterday) Mar 31
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/autoload/dist/ft.vim:

> @@ -1057,6 +1067,15 @@ export def FTr()
   endif
 enddef
 
+export def FTrtn()
+  if exists("g:filetype_rtn")
+    exe "setf " .. g:filetype_rtn

we only need such a variable, if the same extension is used for different file types.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4039496868@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 4:28:24 PM (yesterday) Mar 31
to vim/vim, Push

@hkimura-intersys pushed 1 commit.

  • 6bf5b46 fix: remove unnecessary overrule var


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/before/883d2e2f4b583c0f66d81fa76e24815117aca6a1/after/6bf5b46a3204747bb26ff1c53767ee16679a33b9@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 4:29:32 PM (yesterday) Mar 31
to vim/vim, Subscribed

@hkimura-intersys commented on this pull request.


In runtime/autoload/dist/ft.vim:

> @@ -1057,6 +1067,15 @@ export def FTr()
   endif
 enddef
 
+export def FTrtn()
+  if exists("g:filetype_rtn")
+    exe "setf " .. g:filetype_rtn

sounds good, just removed it. Thank you!


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4039967921@github.com>

zeertzjq

unread,
Mar 31, 2026, 8:27:12 PM (yesterday) Mar 31
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/testdir/test_filetype.vim:

> @@ -601,6 +601,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     obj: ['file.obj'],
     objdump: ['file.objdump', 'file.cppobjdump'],
     obse: ['file.obl', 'file.obse', 'file.oblivion', 'file.obscript'],
+    objectscript_routine: ['file.rtn'],

This should come between objdump and obse.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4041002346@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 8:53:51 PM (24 hours ago) Mar 31
to vim/vim, Push

@hkimura-intersys pushed 1 commit.

  • 91d0129 fix: make test be correct order


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/before/6bf5b46a3204747bb26ff1c53767ee16679a33b9/after/91d01294b18e75f3217ee8f7f203e18d2cac9cfc@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 8:54:01 PM (24 hours ago) Mar 31
to vim/vim, Subscribed

@hkimura-intersys commented on this pull request.


In src/testdir/test_filetype.vim:

> @@ -601,6 +601,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     obj: ['file.obj'],
     objdump: ['file.objdump', 'file.cppobjdump'],
     obse: ['file.obl', 'file.obse', 'file.oblivion', 'file.obscript'],
+    objectscript_routine: ['file.rtn'],

updated, thank you!


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4041067320@github.com>

zeertzjq

unread,
Mar 31, 2026, 9:00:12 PM (24 hours ago) Mar 31
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In runtime/autoload/dist/ft.vim:

> +  if line1 =~? 'iris'
+    return true
+  endif

The iris pattern seems a bit too broad. Is there is strict pattern?


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4041081977@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 9:39:35 PM (23 hours ago) Mar 31
to vim/vim, Push

@hkimura-intersys pushed 1 commit.

  • f2d7436 fix: add word boundary for iris check


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/before/91d01294b18e75f3217ee8f7f203e18d2cac9cfc/after/f2d7436bec9978733bd17176589920d0c1ed66fe@github.com>

Hannah Kimura

unread,
Mar 31, 2026, 9:42:40 PM (23 hours ago) Mar 31
to vim/vim, Subscribed

@hkimura-intersys commented on this pull request.


In runtime/autoload/dist/ft.vim:

> +  if line1 =~? 'iris'
+    return true
+  endif

I updated it to check for word boundaries


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19873/review/4041210305@github.com>

Reply all
Reply to author
Forward
0 new messages