setf typst
enddef
+# Detect Microsoft Developer Studio Project files (Makefile) or Faust DSP
+# files.
+export def FTdsp()
+ if exists("g:filetype_dsp")
+ exe "setf " .. g:filetype_dsp
+ return
+ endif
+
+ # Test the filename
+ if expand('%:t') =~ '^[mM]akefile.*$'
+ setf make
+ return
+ endif
+
+ # Test the file contents
+ for line in getline(1, 200)
+ # Chech for comment style
+ if line =~ '^#.*'
+ setf make
+ return
+ endif
+
+ # Check for common lines
+ if line =~ '^.*Microsoft Developer Studio Project File.*$'
+ setf make
+ return
+ endif
+
+ if line =~ '^!MESSAGE This is not a valid makefile\..+$'
+ setf make
+ return
+ endif
+
+ # Check for keywords
+ if line =~ '^!(IF,ELSEIF,ENDIF).*$'
+ setf make
+ return
+ endif
+
+ # Check for common assignments
+ if line =~ '^SOURCE=.*$'
+ setf make
+ return
+ endif
+ endfor
+
+ # Otherwise, assume we have a Faust file
+ setf faust
+enddef
+
# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200
# lines.
export def FTv()
au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc
" Cobol
-au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol
+au BufNewFile,BufRead *.cbl,*.cob setf cobol
" cobol or zope form controller python script? (heuristic)
au BufNewFile,BufRead *.cpy
\ if getline(1) =~ '^##' |
" Fontconfig config files
au BufNewFile,BufRead fonts.conf setf xml
+" Faust
+au BufNewFile,BufRead *.lib setf faust
+au BufNewFile,BufRead *.dsp call dist#ft#FTdsp()
+
" Libreoffice config files
au BufNewFile,BufRead *.xcu,*.xlb,*.xlc,*.xba setf xml
au BufNewFile,BufRead psprint.conf,sofficerc setf dosini
au BufNewFile,BufRead .mailcap,mailcap setf mailcap
" Makefile
-au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
-au BufNewFile,BufRead Kbuild setf make
+au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak setf make
+au BufNewFile,BufRead Kbuild setf make
" MakeIndex
au BufNewFile,BufRead *.ist,*.mst setf ist
cmakecache: ['CMakeCache.txt'],
cmod: ['file.cmod'],
cmusrc: ['any/.cmus/autosave', 'any/.cmus/rc', 'any/.cmus/command-history', 'any/.cmus/file.theme', 'any/cmus/rc', 'any/cmus/file.theme', '/.cmus/autosave', '/.cmus/command-history', '/.cmus/file.theme', '/.cmus/rc', '/cmus/file.theme', '/cmus/rc'],
- cobol: ['file.cbl', 'file.cob', 'file.lib'],
+ cobol: ['file.cbl', 'file.cob'],
coco: ['file.atg'],
conaryrecipe: ['file.recipe'],
conf: ['auto.master', 'file.conf', 'texdoc.cnf', '.x11vncrc', '.chktexrc', '.ripgreprc', 'ripgreprc', 'file.ctags', '.mbsyncrc'],
factor: ['file.factor'],
falcon: ['file.fal'],
fan: ['file.fan', 'file.fwt'],
+ faust: ['file.dsp', 'file.lib'],
fennel: ['file.fnl'],
fetchmail: ['.fetchmailrc'],
fgl: ['file.4gl', 'file.4gh', 'file.m4gl'],
mail: ['snd.123', '.letter', '.letter.123', '.followup', '.article', '.article.123', 'pico.123', 'mutt-xx-xxx', 'muttng-xx-xxx', 'ae123.txt', 'file.eml', 'reportbug-file'],
mailaliases: ['/etc/mail/aliases', '/etc/aliases', 'any/etc/aliases', 'any/etc/mail/aliases'],
mailcap: ['.mailcap', 'mailcap'],
- make: ['file.mk', 'file.mak', 'file.dsp', 'makefile', 'Makefile', 'makefile-file', 'Makefile-file', 'some-makefile', 'some-Makefile', 'Kbuild'],
+ make: ['file.mk', 'file.mak', 'makefile', 'Makefile', 'makefile-file', 'Makefile-file', 'some-makefile', 'some-Makefile', 'Kbuild'],
mallard: ['file.page'],
man: ['file.man'],
manconf: ['/etc/man.conf', 'man.config', 'any/etc/man.conf'],
filetype off
endfunc
+func Test_dsp_file()
+ filetype on
+
+ " Microsoft Developer Studio Project file
+
+ call writefile(['# Microsoft Developer Studio Project File'], 'Xfile.dsp', 'D')
+ split Xfile.dsp
+ call assert_equal('make', &filetype)
+ bwipe!
+
+ let g:filetype_dsp = 'make'
+ split test.dsp
+ call assert_equal('make', &filetype)
+ bwipe!
+ unlet g:filetype_dsp
+
+ " Faust
+
+ call writefile(['this is a fallback'], 'Xfile.dsp')
+ split Xfile.dsp
+ call assert_equal('faust', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
func Test_vba_file()
filetype on