Extends *.rtn filetype detection to recognize ObjectScript Routines.
*.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.
runtime/filetype.vim
*.rtn to dist#ft#FTrtn()runtime/autoload/dist/ft.vim (FTrtn()):
IsObjectScriptRoutine()) to also check for compiled headers in the first three linesExtended src/testdir/test_filetype.vim with routine detection coverage:
Test_rtn_file()
https://github.com/vim/vim/pull/19873
(4 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
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.![]()
thanks, but
objectscript_routineis 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.![]()
@hkimura-intersys pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
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.![]()
@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.![]()
@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.![]()
@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.![]()
@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.![]()
@hkimura-intersys pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@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.![]()
@hkimura-intersys pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@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.![]()
@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.![]()
@hkimura-intersys pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@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.![]()
@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.![]()
@hkimura-intersys pushed 1 commit.
—
View it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@hkimura-intersys commented on this pull request.
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.![]()