Patch 8.2.4746
Problem: Supercollider filetype not recognized.
Solution: Match file extentions and check file contents to detect
supercollider. (closes #10142)
Files: runtime/filetype.vim, runtime/autoload/dist/ft.vim,
src/testdir/test_filetype.vim
*** ../vim-8.2.4745/runtime/filetype.vim 2022-04-11 11:37:07.994510794 +0100
--- runtime/filetype.vim 2022-04-13 15:25:58.303597864 +0100
***************
*** 206,217 ****
au BufNewFile,BufRead *.fb setf freebasic
" Batch file for MSDOS. See dist#ft#FTsys for *.sys
! au BufNewFile,BufRead *.bat setf dosbatch
" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
au BufNewFile,BufRead *.cmd
\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
" ABB RAPID or Batch file for MSDOS.
! au BufNewFile,BufRead *.sys\c call dist#ft#FTsys()
" Batch file for 4DOS
au BufNewFile,BufRead *.btm call dist#ft#FTbtm()
--- 206,217 ----
au BufNewFile,BufRead *.fb setf freebasic
" Batch file for MSDOS. See dist#ft#FTsys for *.sys
! au BufNewFile,BufRead *.bat setf dosbatch
" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
au BufNewFile,BufRead *.cmd
\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
" ABB RAPID or Batch file for MSDOS.
! au BufNewFile,BufRead *.sys\c call dist#ft#FTsys()
" Batch file for 4DOS
au BufNewFile,BufRead *.btm call dist#ft#FTbtm()
***************
*** 1144,1150 ****
au BufNewFile,BufRead *.mmp setf mmp
" ABB Rapid, Modula-2, Modsim III or LambdaProlog
! au BufNewFile,BufRead *.mod\c call dist#ft#FTmod()
" Modula-2 (.md removed in favor of Markdown, see dist#ft#FTmod for *.MOD)
au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2
--- 1144,1150 ----
au BufNewFile,BufRead *.mmp setf mmp
" ABB Rapid, Modula-2, Modsim III or LambdaProlog
! au BufNewFile,BufRead *.mod\c call dist#ft#FTmod()
" Modula-2 (.md removed in favor of Markdown, see dist#ft#FTmod for *.MOD)
au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2
***************
*** 1634,1649 ****
au BufNewFile,BufRead *.sa setf sather
" Scala
! au BufNewFile,BufRead *.scala,*.sc setf scala
" SBT - Scala Build Tool
au BufNewFile,BufRead *.sbt setf sbt
" Scilab
au BufNewFile,BufRead *.sci,*.sce setf scilab
- " scdoc
- au BufNewFile,BufRead *.scd setf scdoc
" SCSS
au BufNewFile,BufRead *.scss setf scss
--- 1634,1655 ----
au BufNewFile,BufRead *.sa setf sather
" Scala
! au BufNewFile,BufRead *.scala setf scala
" SBT - Scala Build Tool
au BufNewFile,BufRead *.sbt setf sbt
+ " SuperCollider
+ au BufNewFile,BufRead *.sc call dist#ft#FTsc()
+
+ au BufNewFile,BufRead *.quark setf supercollider
+
+ " scdoc
+ au BufNewFile,BufRead *.scd call dist#ft#FTscd()
+
" Scilab
au BufNewFile,BufRead *.sci,*.sce setf scilab
" SCSS
au BufNewFile,BufRead *.scss setf scss
*** ../vim-8.2.4745/runtime/autoload/dist/ft.vim 2022-04-09 15:16:18.468503702 +0100
--- runtime/autoload/dist/ft.vim 2022-04-13 15:25:04.647636087 +0100
***************
*** 769,774 ****
--- 769,796 ----
endif
enddef
+ # This function checks the first 25 lines of file extension "sc" to resolve
+ # detection between scala and SuperCollider
+ export def FTsc()
+ for lnum in range(1, min([line("$"), 25]))
+ if getline(lnum) =~# '[A-Za-z0-9]*\s:\s[A-Za-z0-9]\|var\s<\|classvar\s<\|\^this.*\||\w*|\|+\s\w*\s{\|\*ar\s'
+ setf supercollider
+ return
+ endif
+ endfor
+ setf scala
+ enddef
+
+ # This function checks the first line of file extension "scd" to resolve
+ # detection between scdoc and SuperCollider
+ export def FTscd()
+ if getline(1) =~# '\%^\S\+(\d[0-9A-Za-z]*)\%(\s\+\"[^"]*\"\%(\s\+\"[^"]*\"\)\=\)\=$'
+ setf scdoc
+ else
+ setf supercollider
+ endif
+ enddef
+
# If the file has an extension of 't' and is in a directory 't' or 'xt' then
# it is almost certainly a Perl test file.
# If the first line starts with '#' and contains 'perl' it's probably a Perl
*** ../vim-8.2.4745/src/testdir/test_filetype.vim 2022-04-11 11:37:07.994510794 +0100
--- src/testdir/test_filetype.vim 2022-04-13 15:26:25.523578593 +0100
***************
*** 464,475 ****
\ 'sass': ['file.sass'],
\ 'sather': ['
file.sa'],
\ 'sbt': ['file.sbt'],
! \ 'scala': ['file.scala', '
file.sc'],
\ 'scheme': ['file.scm', 'file.ss', 'file.sld', 'file.rkt', 'file.rktd', 'file.rktl'],
\ 'scilab': ['file.sci', 'file.sce'],
\ 'screen': ['.screenrc', 'screenrc'],
\ 'sexplib': ['file.sexp'],
- \ 'scdoc': ['file.scd'],
\ 'scss': ['file.scss'],
\ 'sd': ['
file.sd'],
\ 'sdc': ['file.sdc'],
--- 464,474 ----
\ 'sass': ['file.sass'],
\ 'sather': ['
file.sa'],
\ 'sbt': ['file.sbt'],
! \ 'scala': ['file.scala'],
\ 'scheme': ['file.scm', 'file.ss', 'file.sld', 'file.rkt', 'file.rktd', 'file.rktl'],
\ 'scilab': ['file.sci', 'file.sce'],
\ 'screen': ['.screenrc', 'screenrc'],
\ 'sexplib': ['file.sexp'],
\ 'scss': ['file.scss'],
\ 'sd': ['
file.sd'],
\ 'sdc': ['file.sdc'],
***************
*** 517,522 ****
--- 516,522 ----
\ 'stata': ['file.ado', 'file.do', 'file.imata', 'file.mata'],
\ 'stp': ['file.stp'],
\ 'sudoers': ['any/etc/sudoers', 'sudoers.tmp', '/etc/sudoers', 'any/etc/sudoers.d/file'],
+ \ 'supercollider': ['file.quark'],
\ 'surface': ['file.sface'],
\ 'svg': ['file.svg'],
\ 'svn': ['svn-commitfile.tmp', 'svn-commit-file.tmp', 'svn-commit.tmp'],
***************
*** 1495,1500 ****
--- 1495,1548 ----
filetype off
endfunc
+
+ " Test dist#ft#FTsc()
+ func Test_sc_file()
+ filetype on
+
+ " SC file mehtods are defined 'Class : Method'
+ call writefile(['SCNvimDocRenderer : SCDocHTMLRenderer {'], '
srcfile.sc')
+ split
srcfile.sc
+ call assert_equal('supercollider', &filetype)
+ bwipe!
+ call delete('
srcfile.sc')
+
+ " SC classes are defined with '+ Class {}'
+ call writefile(['+ SCNvim {', '*methodArgs {|method|'], '
srcfile.sc')
+ split
srcfile.sc
+ call assert_equal('supercollider', &filetype)
+ bwipe!
+ call delete('
srcfile.sc')
+
+ " Some SC class files start with comment and define methods many lines later
+ call writefile(['// Query', '//Method','^this {'], '
srcfile.sc')
+ split
srcfile.sc
+ call assert_equal('supercollider', &filetype)
+ bwipe!
+ call delete('
srcfile.sc')
+
+ " Some SC class files put comments between method declaration after class
+ call writefile(['PingPong {', '//comment','*ar { arg'], '
srcfile.sc')
+ split
srcfile.sc
+ call assert_equal('supercollider', &filetype)
+ bwipe!
+ call delete('
srcfile.sc')
+
+ filetype off
+ endfunc
+
+ " Test dist#ft#FTscd()
+ func Test_scd_file()
+ filetype on
+
+ call writefile(['ijq(1)'], 'srcfile.scd')
+ split srcfile.scd
+ call assert_equal('scdoc', &filetype)
+ bwipe!
+ call delete('srcfile.scd')
+
+ filetype off
+ endfunc
func Test_src_file()
filetype on
*** ../vim-8.2.4745/src/version.c 2022-04-13 14:28:03.749082509 +0100
--- src/version.c 2022-04-13 15:21:03.011813624 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4746,
/**/
--
Team-building exercises come in many forms but they all trace their roots back
to the prison system. In your typical team-building exercise the employees
are subjected to a variety of unpleasant situations until they become either a
cohesive team or a ring of car jackers.
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///