summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorranjithshegde <ranjithshegde@gmail.com>2022-04-13 15:29:21 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-13 15:29:21 +0100
commit8cac20ed42b7b7fc9c6b54e3055ca1047f50b8ca (patch)
treebd21709fd4bb8df7694ce06e12e50ac17ab7e690 /runtime
parentaae9762b2cbcae8dea454e1701d00ea0f614175e (diff)
downloadvim-git-8cac20ed42b7b7fc9c6b54e3055ca1047f50b8ca.tar.gz
patch 8.2.4746: supercollider filetype not recognizedv8.2.4746
Problem: Supercollider filetype not recognized. Solution: Match file extentions and check file contents to detect supercollider. (closes #10142)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/dist/ft.vim22
-rw-r--r--runtime/filetype.vim18
2 files changed, 34 insertions, 6 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 3bf552a1a..ff554dfe8 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -769,6 +769,28 @@ export def SQL()
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
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 62afb375c..500f46923 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -206,12 +206,12 @@ au BufNewFile,BufRead *.iba,*.ibi setf ibasic
au BufNewFile,BufRead *.fb setf freebasic
" 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.
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()
+au BufNewFile,BufRead *.sys\c call dist#ft#FTsys()
" Batch file for 4DOS
au BufNewFile,BufRead *.btm call dist#ft#FTbtm()
@@ -1144,7 +1144,7 @@ au BufNewFile,BufRead *.mms call dist#ft#FTmms()
au BufNewFile,BufRead *.mmp setf mmp
" 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)
au BufNewFile,BufRead *.m2,*.DEF,*.mi setf modula2
@@ -1634,16 +1634,22 @@ au BufNewFile,BufRead *.sass setf sass
au BufNewFile,BufRead *.sa setf sather
" Scala
-au BufNewFile,BufRead *.scala,*.sc setf 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
-" scdoc
-au BufNewFile,BufRead *.scd setf scdoc
" SCSS
au BufNewFile,BufRead *.scss setf scss