mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.4746: supercollider filetype not recognized (#18102)
Problem: Supercollider filetype not recognized.
Solution: Match file extentions and check file contents to detect
supercollider. (closes vim/vim#10142)
8cac20ed42
This commit is contained in:
parent
7d1142b7e7
commit
9938740ca6
22
runtime/autoload/dist/ft.vim
vendored
22
runtime/autoload/dist/ft.vim
vendored
@ -773,6 +773,28 @@ func dist#ft#SQL()
|
|||||||
endif
|
endif
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" This function checks the first 25 lines of file extension "sc" to resolve
|
||||||
|
" detection between scala and SuperCollider
|
||||||
|
func dist#ft#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
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" This function checks the first line of file extension "scd" to resolve
|
||||||
|
" detection between scdoc and SuperCollider
|
||||||
|
func dist#ft#FTscd()
|
||||||
|
if getline(1) =~# '\%^\S\+(\d[0-9A-Za-z]*)\%(\s\+\"[^"]*\"\%(\s\+\"[^"]*\"\)\=\)\=$'
|
||||||
|
setf scdoc
|
||||||
|
else
|
||||||
|
setf supercollider
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
" If the file has an extension of 't' and is in a directory 't' or 'xt' then
|
" 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.
|
" it is almost certainly a Perl test file.
|
||||||
" If the first line starts with '#' and contains 'perl' it's probably a Perl
|
" If the first line starts with '#' and contains 'perl' it's probably a Perl
|
||||||
|
@ -202,12 +202,12 @@ au BufNewFile,BufRead *.iba,*.ibi setf ibasic
|
|||||||
au BufNewFile,BufRead *.fb setf freebasic
|
au BufNewFile,BufRead *.fb setf freebasic
|
||||||
|
|
||||||
" Batch file for MSDOS. See dist#ft#FTsys for *.sys
|
" Batch file for MSDOS. See dist#ft#FTsys for *.sys
|
||||||
au BufNewFile,BufRead *.bat setf dosbatch
|
au BufNewFile,BufRead *.bat setf dosbatch
|
||||||
" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
|
" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
|
||||||
au BufNewFile,BufRead *.cmd
|
au BufNewFile,BufRead *.cmd
|
||||||
\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
|
\ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
|
||||||
" ABB RAPID or Batch file for MSDOS.
|
" ABB RAPID or Batch file for MSDOS.
|
||||||
au BufNewFile,BufRead *.sys\c call dist#ft#FTsys()
|
au BufNewFile,BufRead *.sys\c call dist#ft#FTsys()
|
||||||
|
|
||||||
" Batch file for 4DOS
|
" Batch file for 4DOS
|
||||||
au BufNewFile,BufRead *.btm call dist#ft#FTbtm()
|
au BufNewFile,BufRead *.btm call dist#ft#FTbtm()
|
||||||
@ -1140,7 +1140,7 @@ au BufNewFile,BufRead *.mms call dist#ft#FTmms()
|
|||||||
au BufNewFile,BufRead *.mmp setf mmp
|
au BufNewFile,BufRead *.mmp setf mmp
|
||||||
|
|
||||||
" ABB Rapid, Modula-2, Modsim III or LambdaProlog
|
" ABB Rapid, Modula-2, Modsim III or LambdaProlog
|
||||||
au BufNewFile,BufRead *.mod\c call dist#ft#FTmod()
|
au BufNewFile,BufRead *.mod\c call dist#ft#FTmod()
|
||||||
|
|
||||||
" Modula-2 (.md removed in favor of Markdown, see dist#ft#FTmod for *.MOD)
|
" Modula-2 (.md removed in favor of Markdown, see dist#ft#FTmod for *.MOD)
|
||||||
au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2
|
au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2
|
||||||
@ -1630,16 +1630,22 @@ au BufNewFile,BufRead *.sass setf sass
|
|||||||
au BufNewFile,BufRead *.sa setf sather
|
au BufNewFile,BufRead *.sa setf sather
|
||||||
|
|
||||||
" Scala
|
" Scala
|
||||||
au BufNewFile,BufRead *.scala,*.sc setf scala
|
au BufNewFile,BufRead *.scala setf scala
|
||||||
|
|
||||||
" SBT - Scala Build Tool
|
" SBT - Scala Build Tool
|
||||||
au BufNewFile,BufRead *.sbt setf sbt
|
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
|
" Scilab
|
||||||
au BufNewFile,BufRead *.sci,*.sce setf scilab
|
au BufNewFile,BufRead *.sci,*.sce setf scilab
|
||||||
|
|
||||||
" scdoc
|
|
||||||
au BufNewFile,BufRead *.scd setf scdoc
|
|
||||||
|
|
||||||
" SCSS
|
" SCSS
|
||||||
au BufNewFile,BufRead *.scss setf scss
|
au BufNewFile,BufRead *.scss setf scss
|
||||||
|
@ -569,8 +569,6 @@ local extension = {
|
|||||||
sa = "sather",
|
sa = "sather",
|
||||||
sbt = "sbt",
|
sbt = "sbt",
|
||||||
scala = "scala",
|
scala = "scala",
|
||||||
sc = "scala",
|
|
||||||
scd = "scdoc",
|
|
||||||
ss = "scheme",
|
ss = "scheme",
|
||||||
scm = "scheme",
|
scm = "scheme",
|
||||||
sld = "scheme",
|
sld = "scheme",
|
||||||
@ -644,6 +642,7 @@ local extension = {
|
|||||||
mata = "stata",
|
mata = "stata",
|
||||||
ado = "stata",
|
ado = "stata",
|
||||||
stp = "stp",
|
stp = "stp",
|
||||||
|
quark = "supercollider",
|
||||||
sface = "surface",
|
sface = "surface",
|
||||||
svelte = "svelte",
|
svelte = "svelte",
|
||||||
svg = "svg",
|
svg = "svg",
|
||||||
@ -830,6 +829,8 @@ local extension = {
|
|||||||
r = function() vim.fn["dist#ft#FTr"]() end,
|
r = function() vim.fn["dist#ft#FTr"]() end,
|
||||||
rdf = function() vim.fn["dist#ft#Redif"]() end,
|
rdf = function() vim.fn["dist#ft#Redif"]() end,
|
||||||
rules = function() vim.fn["dist#ft#FTRules"]() end,
|
rules = function() vim.fn["dist#ft#FTRules"]() end,
|
||||||
|
sc = function() vim.fn["dist#ft#FTsc"]() end,
|
||||||
|
scd = function() vim.fn["dist#ft#FTscd"]() end,
|
||||||
sh = function() vim.fn["dist#ft#SetFileTypeSH"](vim.fn.getline(1)) end,
|
sh = function() vim.fn["dist#ft#SetFileTypeSH"](vim.fn.getline(1)) end,
|
||||||
shtml = function() vim.fn["dist#ft#FThtml"]() end,
|
shtml = function() vim.fn["dist#ft#FThtml"]() end,
|
||||||
sql = function() vim.fn["dist#ft#SQL"]() end,
|
sql = function() vim.fn["dist#ft#SQL"]() end,
|
||||||
|
@ -463,12 +463,11 @@ let s:filename_checks = {
|
|||||||
\ 'sass': ['file.sass'],
|
\ 'sass': ['file.sass'],
|
||||||
\ 'sather': ['file.sa'],
|
\ 'sather': ['file.sa'],
|
||||||
\ 'sbt': ['file.sbt'],
|
\ 'sbt': ['file.sbt'],
|
||||||
\ 'scala': ['file.scala', 'file.sc'],
|
\ 'scala': ['file.scala'],
|
||||||
\ 'scheme': ['file.scm', 'file.ss', 'file.sld', 'file.rkt', 'file.rktd', 'file.rktl'],
|
\ 'scheme': ['file.scm', 'file.ss', 'file.sld', 'file.rkt', 'file.rktd', 'file.rktl'],
|
||||||
\ 'scilab': ['file.sci', 'file.sce'],
|
\ 'scilab': ['file.sci', 'file.sce'],
|
||||||
\ 'screen': ['.screenrc', 'screenrc'],
|
\ 'screen': ['.screenrc', 'screenrc'],
|
||||||
\ 'sexplib': ['file.sexp'],
|
\ 'sexplib': ['file.sexp'],
|
||||||
\ 'scdoc': ['file.scd'],
|
|
||||||
\ 'scss': ['file.scss'],
|
\ 'scss': ['file.scss'],
|
||||||
\ 'sd': ['file.sd'],
|
\ 'sd': ['file.sd'],
|
||||||
\ 'sdc': ['file.sdc'],
|
\ 'sdc': ['file.sdc'],
|
||||||
@ -516,6 +515,7 @@ let s:filename_checks = {
|
|||||||
\ 'stata': ['file.ado', 'file.do', 'file.imata', 'file.mata'],
|
\ 'stata': ['file.ado', 'file.do', 'file.imata', 'file.mata'],
|
||||||
\ 'stp': ['file.stp'],
|
\ 'stp': ['file.stp'],
|
||||||
\ 'sudoers': ['any/etc/sudoers', 'sudoers.tmp', '/etc/sudoers', 'any/etc/sudoers.d/file'],
|
\ 'sudoers': ['any/etc/sudoers', 'sudoers.tmp', '/etc/sudoers', 'any/etc/sudoers.d/file'],
|
||||||
|
\ 'supercollider': ['file.quark'],
|
||||||
\ 'surface': ['file.sface'],
|
\ 'surface': ['file.sface'],
|
||||||
\ 'svg': ['file.svg'],
|
\ 'svg': ['file.svg'],
|
||||||
\ 'svn': ['svn-commitfile.tmp', 'svn-commit-file.tmp', 'svn-commit.tmp'],
|
\ 'svn': ['svn-commitfile.tmp', 'svn-commit-file.tmp', 'svn-commit.tmp'],
|
||||||
@ -1470,6 +1470,54 @@ func Test_prg_file()
|
|||||||
filetype off
|
filetype off
|
||||||
endfunc
|
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()
|
func Test_src_file()
|
||||||
filetype on
|
filetype on
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user