1" Test :setfiletype 2 3func Test_detection() 4 filetype on 5 augroup filetypedetect 6 au BufNewFile,BufRead * call assert_equal(1, did_filetype()) 7 augroup END 8 new something.vim 9 call assert_equal('vim', &filetype) 10 11 bwipe! 12 filetype off 13endfunc 14 15func Test_conf_type() 16 filetype on 17 call writefile(['# some comment', 'must be conf'], 'Xfile') 18 augroup filetypedetect 19 au BufNewFile,BufRead * call assert_equal(0, did_filetype()) 20 augroup END 21 split Xfile 22 call assert_equal('conf', &filetype) 23 24 bwipe! 25 call delete('Xfile') 26 filetype off 27endfunc 28 29func Test_other_type() 30 filetype on 31 augroup filetypedetect 32 au BufNewFile,BufRead * call assert_equal(0, did_filetype()) 33 au BufNewFile,BufRead Xfile setf testfile 34 au BufNewFile,BufRead * call assert_equal(1, did_filetype()) 35 augroup END 36 call writefile(['# some comment', 'must be conf'], 'Xfile') 37 split Xfile 38 call assert_equal('testfile', &filetype) 39 40 bwipe! 41 call delete('Xfile') 42 filetype off 43endfunc 44 45" Filetypes detected just from matching the file name. 46let s:filename_checks = { 47 \ 'a2ps': ['/etc/a2ps.cfg', '/etc/a2ps/file.cfg', 'a2psrc', '.a2psrc'], 48 \ 'a65': ['file.a65'], 49 \ 'abap': ['file.abap'], 50 \ 'abc': ['file.abc'], 51 \ 'abel': ['file.abl'], 52 \ 'acedb': ['file.wrm'], 53 \ 'ada': ['file.adb', 'file.ads', 'file.ada', 'file.gpr'], 54 \ 'ahdl': ['file.tdf'], 55 \ 'alsaconf': ['.asoundrc', '/usr/share/alsa/alsa.conf', '/etc/asound.conf'], 56 \ 'aml': ['file.aml'], 57 \ 'ampl': ['file.run'], 58 \ 'ant': ['build.xml'], 59 \ 'apache': ['.htaccess', '/etc/httpd/file.conf'], 60 \ 'applescript': ['file.scpt'], 61 \ 'aptconf': ['apt.conf', '/.aptitude/config'], 62 \ 'arch': ['.arch-inventory'], 63 \ 'arduino': ['file.ino', 'file.pde'], 64 \ 'art': ['file.art'], 65 \ 'asciidoc': ['file.asciidoc', 'file.adoc'], 66 \ 'asn': ['file.asn', 'file.asn1'], 67 \ 'atlas': ['file.atl', 'file.as'], 68 \ 'autohotkey': ['file.ahk'], 69 \ 'autoit': ['file.au3'], 70 \ 'automake': ['GNUmakefile.am'], 71 \ 'ave': ['file.ave'], 72 \ 'awk': ['file.awk'], 73 \ 'b': ['file.mch', 'file.ref', 'file.imp'], 74 \ 'bc': ['file.bc'], 75 \ 'bdf': ['file.bdf'], 76 \ 'bib': ['file.bib'], 77 \ 'bindzone': ['named.root'], 78 \ 'blank': ['file.bl'], 79 \ 'bst': ['file.bst'], 80 \ 'bzr': ['bzr_log.any'], 81 \ 'c': ['enlightenment/file.cfg', 'file.qc', 'file.c'], 82 \ 'cabal': ['file.cabal'], 83 \ 'calendar': ['calendar'], 84 \ 'catalog': ['catalog'], 85 \ 'cdl': ['file.cdl'], 86 \ 'cdrdaoconf': ['/etc/cdrdao.conf', '/etc/defaults/cdrdao', '/etc/default/cdrdao', '.cdrdao'], 87 \ 'cdrtoc': ['file.toc'], 88 \ 'cf': ['file.cfm', 'file.cfi', 'file.cfc'], 89 \ 'cfengine': ['cfengine.conf'], 90 \ 'cfg': ['file.cfg', 'file.hgrc', 'filehgrc'], 91 \ 'ch': ['file.chf'], 92 \ 'chaiscript': ['file.chai'], 93 \ 'chaskell': ['file.chs'], 94 \ 'chill': ['file..ch'], 95 \ 'chordpro': ['file.chopro', 'file.crd', 'file.cho', 'file.crdpro', 'file.chordpro'], 96 \ 'cl': ['file.eni'], 97 \ 'clean': ['file.dcl', 'file.icl'], 98 \ 'clojure': ['file.clj', 'file.cljs', 'file.cljx', 'file.cljc'], 99 \ 'cmake': ['CMakeLists.txt', 'file.cmake', 'file.cmake.in'], 100 \ 'cmusrc': ['any/.cmus/autosave', 'any/.cmus/rc', 'any/.cmus/command-history', 'any/.cmus/file.theme', 'any/cmus/rc', 'any/cmus/file.theme'], 101 \ 'cobol': ['file.cbl', 'file.cob', 'file.lib'], 102 \ 'coco': ['file.atg'], 103 \ 'conaryrecipe': ['file.recipe'], 104 \ 'conf': ['auto.master'], 105 \ 'config': ['configure.in', 'configure.ac', 'Pipfile'], 106 \ 'context': ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi'], 107 \ 'cpp': ['file.cxx', 'file.c++', 'file.hh', 'file.hxx', 'file.hpp', 'file.ipp', 'file.moc', 'file.tcc', 'file.inl', 'file.tlh'], 108 \ 'crm': ['file.crm'], 109 \ 'cs': ['file.cs'], 110 \ 'csc': ['file.csc'], 111 \ 'csdl': ['file.csdl'], 112 \ 'csp': ['file.csp', 'file.fdr'], 113 \ 'css': ['file.css'], 114 \ 'cterm': ['file.con'], 115 \ 'cucumber': ['file.feature'], 116 \ 'cuda': ['file.cu'], 117 \ 'cupl': ['file.pld'], 118 \ 'cuplsim': ['file.si'], 119 \ 'cvs': ['cvs123'], 120 \ 'cvsrc': ['.cvsrc'], 121 \ 'cynpp': ['file.cyn'], 122 \ 'datascript': ['file.ds'], 123 \ 'dcd': ['file.dcd'], 124 \ 'debcontrol': ['/debian/control'], 125 \ 'debsources': ['/etc/apt/sources.list', '/etc/apt/sources.list.d/file.list'], 126 \ 'def': ['file.def'], 127 \ 'denyhosts': ['denyhosts.conf'], 128 \ 'desc': ['file.desc'], 129 \ 'desktop': ['file.desktop', '.directory'], 130 \ 'dictconf': ['dict.conf', '.dictrc'], 131 \ 'dictdconf': ['dictd.conf'], 132 \ 'diff': ['file.diff', 'file.rej'], 133 \ 'dircolors': ['.dir_colors', '.dircolors', '/etc/DIR_COLORS'], 134 \ 'dnsmasq': ['/etc/dnsmasq.conf'], 135 \ 'dockerfile': ['Dockerfile', 'file.Dockerfile'], 136 \ 'dosbatch': ['file.bat', 'file.sys'], 137 \ 'dosini': ['.editorconfig', '/etc/yum.conf', 'file.ini'], 138 \ 'dot': ['file.dot'], 139 \ 'dracula': ['file.drac', 'file.drc', 'filelvs', 'filelpe'], 140 \ 'dsl': ['file.dsl'], 141 \ 'dtd': ['file.dtd'], 142 \ 'dts': ['file.dts', 'file.dtsi'], 143 \ 'dylan': ['file.dylan'], 144 \ 'dylanintr': ['file.intr'], 145 \ 'dylanlid': ['file.lid'], 146 \ 'ecd': ['file.ecd'], 147 \ 'edif': ['file.edf', 'file.edif', 'file.edo'], 148 \ 'elinks': ['/etc/elinks.conf', '/.elinks/elinks.conf'], 149 \ 'elmfilt': ['filter-rules'], 150 \ 'erlang': ['file.erl', 'file.hrl', 'file.yaws'], 151 \ 'eruby': ['file.erb', 'file.rhtml'], 152 \ 'esmtprc': ['anyesmtprc'], 153 \ 'esqlc': ['file.ec', 'file.EC'], 154 \ 'esterel': ['file.strl'], 155 \ 'eterm': ['anyEterm/file.cfg'], 156 \ 'exim': ['exim.conf'], 157 \ 'expect': ['file.exp'], 158 \ 'exports': ['exports'], 159 \ 'factor': ['file.factor'], 160 \ 'falcon': ['file.fal'], 161 \ 'fan': ['file.fan', 'file.fwt'], 162 \ 'fetchmail': ['.fetchmailrc'], 163 \ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'], 164 \ 'focexec': ['file.fex', 'file.focexec'], 165 \ 'forth': ['file.fs', 'file.ft', 'file.fth'], 166 \ 'fortran': ['file.f', 'file.for', 'file.fortran', 'file.fpp', 'file.ftn', 'file.f77', 'file.f90', 'file.f95', 'file.f03', 'file.f08'], 167 \ 'framescript': ['file.fsl'], 168 \ 'freebasic': ['file.fb', 'file.bi'], 169 \ 'fstab': ['fstab', 'mtab'], 170 \ 'gdb': ['.gdbinit'], 171 \ 'gdmo': ['file.mo', 'file.gdmo'], 172 \ 'gedcom': ['file.ged', 'lltxxxxx.txt'], 173 \ 'gitcommit': ['COMMIT_EDITMSG', 'MERGE_MSG', 'TAG_EDITMSG'], 174 \ 'gitconfig': ['file.git/config', '.gitconfig', '.gitmodules', 'file.git/modules//config', '/.config/git/config', '/etc/gitconfig'], 175 \ 'gitolite': ['gitolite.conf'], 176 \ 'gitrebase': ['git-rebase-todo'], 177 \ 'gitsendemail': ['.gitsendemail.msg.xxxxxx'], 178 \ 'gkrellmrc': ['gkrellmrc', 'gkrellmrc_x'], 179 \ 'gnash': ['gnashrc', '.gnashrc', 'gnashpluginrc', '.gnashpluginrc'], 180 \ 'gnuplot': ['file.gpi'], 181 \ 'go': ['file.go'], 182 \ 'gp': ['file.gp', '.gprc'], 183 \ 'gpg': ['/.gnupg/options', '/.gnupg/gpg.conf', '/usr/any/gnupg/options.skel'], 184 \ 'grads': ['file.gs'], 185 \ 'gretl': ['file.gretl'], 186 \ 'groovy': ['file.gradle', 'file.groovy'], 187 \ 'group': ['any/etc/group', 'any/etc/group-', 'any/etc/group.edit', 'any/etc/gshadow', 'any/etc/gshadow-', 'any/etc/gshadow.edit', 'any/var/backups/group.bak', 'any/var/backups/gshadow.bak'], 188 \ 'grub': ['/boot/grub/menu.lst', '/boot/grub/grub.conf', '/etc/grub.conf'], 189 \ 'gsp': ['file.gsp'], 190 \ 'gtkrc': ['.gtkrc', 'gtkrc'], 191 \ 'haml': ['file.haml'], 192 \ 'hamster': ['file.hsc', 'file.hsm'], 193 \ 'haskell': ['file.hs', 'file.hs-boot'], 194 \ 'haste': ['file.ht'], 195 \ 'hastepreproc': ['file.htpp'], 196 \ 'hb': ['file.hb'], 197 \ 'hercules': ['file.vc', 'file.ev', 'file.sum', 'file.errsum'], 198 \ 'hex': ['file.hex', 'file.h32'], 199 \ 'hgcommit': ['hg-editor-file.txt'], 200 \ 'hog': ['file.hog', 'snort.conf', 'vision.conf'], 201 \ 'hostconf': ['/etc/host.conf'], 202 \ 'hostsaccess': ['/etc/hosts.allow', '/etc/hosts.deny'], 203 \ 'template': ['file.tmpl'], 204 \ 'htmlm4': ['file.html.m4'], 205 \ 'httest': ['file.htt', 'file.htb'], 206 \ 'ibasic': ['file.iba', 'file.ibi'], 207 \ 'icemenu': ['/.icewm/menu'], 208 \ 'icon': ['file.icn'], 209 \ 'indent': ['.indent.pro', 'indentrc'], 210 \ 'inform': ['file.inf', 'file.INF'], 211 \ 'initng': ['/etc/initng/any/file.i', 'file.ii'], 212 \ 'inittab': ['inittab'], 213 \ 'ipfilter': ['ipf.conf', 'ipf6.conf', 'ipf.rules'], 214 \ 'iss': ['file.iss'], 215 \ 'ist': ['file.ist', 'file.mst'], 216 \ 'j': ['file.ijs'], 217 \ 'jal': ['file.jal', 'file.JAL'], 218 \ 'jam': ['file.jpl', 'file.jpr'], 219 \ 'java': ['file.java', 'file.jav'], 220 \ 'javacc': ['file.jj', 'file.jjt'], 221 \ 'javascript': ['file.js', 'file.javascript', 'file.es', 'file.jsx', 'file.mjs'], 222 \ 'jess': ['file.clp'], 223 \ 'jgraph': ['file.jgr'], 224 \ 'jovial': ['file.jov', 'file.j73', 'file.jovial'], 225 \ 'jproperties': ['file.properties', 'file.properties_xx', 'file.properties_xx_xx'], 226 \ 'json': ['file.json', 'file.jsonp', 'file.webmanifest', 'Pipfile.lock'], 227 \ 'jsp': ['file.jsp'], 228 \ 'kconfig': ['Kconfig', 'Kconfig.debug'], 229 \ 'kivy': ['file.kv'], 230 \ 'kix': ['file.kix'], 231 \ 'kscript': ['file.ks'], 232 \ 'kwt': ['file.k'], 233 \ 'lace': ['file.ace', 'file.ACE'], 234 \ 'latte': ['file.latte', 'file.lte'], 235 \ 'ld': ['file.ld'], 236 \ 'ldif': ['file.ldif'], 237 \ 'less': ['file.less'], 238 \ 'lex': ['file.lex', 'file.l', 'file.lxx', 'file.l++'], 239 \ 'lftp': ['lftp.conf', '.lftprc', 'anylftp/rc'], 240 \ 'lhaskell': ['file.lhs'], 241 \ 'libao': ['/etc/libao.conf', '/.libao'], 242 \ 'lifelines': ['file.ll'], 243 \ 'lilo': ['lilo.conf'], 244 \ 'limits': ['/etc/limits', '/etc/anylimits.conf', '/etc/anylimits.d/file.conf'], 245 \ 'liquid': ['file.liquid'], 246 \ 'lisp': ['sbclrc', '.sbclrc'], 247 \ 'lite': ['file.lite', 'file.lt'], 248 \ 'litestep': ['/LiteStep/any/file.rc'], 249 \ 'loginaccess': ['/etc/login.access'], 250 \ 'logindefs': ['/etc/login.defs'], 251 \ 'logtalk': ['file.lgt'], 252 \ 'lotos': ['file.lot', 'file.lotos'], 253 \ 'lout': ['file.lou', 'file.lout'], 254 \ 'lprolog': ['file.sig'], 255 \ 'lsl': ['file.lsl'], 256 \ 'lss': ['file.lss'], 257 \ 'lua': ['file.lua', 'file.rockspec', 'file.nse'], 258 \ 'lynx': ['lynx.cfg'], 259 \ 'm4': ['file.at'], 260 \ 'mail': ['snd.123', '.letter', '.letter.123', '.followup', '.article', '.article.123', 'pico.123', 'mutt-xx-xxx', 'muttng-xx-xxx', 'ae123.txt', 'file.eml'], 261 \ 'mailaliases': ['/etc/mail/aliases', '/etc/aliases'], 262 \ 'mailcap': ['.mailcap', 'mailcap'], 263 \ 'make': ['file.mk', 'file.mak', 'file.dsp'], 264 \ 'mallard': ['file.page'], 265 \ 'man': ['file.man'], 266 \ 'manconf': ['/etc/man.conf', 'man.config'], 267 \ 'map': ['file.map'], 268 \ 'maple': ['file.mv', 'file.mpl', 'file.mws'], 269 \ 'markdown': ['file.markdown', 'file.mdown', 'file.mkd', 'file.mkdn', 'file.mdwn', 'file.md'], 270 \ 'mason': ['file.mason', 'file.mhtml', 'file.comp'], 271 \ 'master': ['file.mas', 'file.master'], 272 \ 'mel': ['file.mel'], 273 \ 'messages': ['/log/auth', '/log/cron', '/log/daemon', '/log/debug', '/log/kern', '/log/lpr', '/log/mail', '/log/messages', '/log/news/news', '/log/syslog', '/log/user', 274 \ '/log/auth.log', '/log/cron.log', '/log/daemon.log', '/log/debug.log', '/log/kern.log', '/log/lpr.log', '/log/mail.log', '/log/messages.log', '/log/news/news.log', '/log/syslog.log', '/log/user.log', 275 \ '/log/auth.err', '/log/cron.err', '/log/daemon.err', '/log/debug.err', '/log/kern.err', '/log/lpr.err', '/log/mail.err', '/log/messages.err', '/log/news/news.err', '/log/syslog.err', '/log/user.err', 276 \ '/log/auth.info', '/log/cron.info', '/log/daemon.info', '/log/debug.info', '/log/kern.info', '/log/lpr.info', '/log/mail.info', '/log/messages.info', '/log/news/news.info', '/log/syslog.info', '/log/user.info', 277 \ '/log/auth.warn', '/log/cron.warn', '/log/daemon.warn', '/log/debug.warn', '/log/kern.warn', '/log/lpr.warn', '/log/mail.warn', '/log/messages.warn', '/log/news/news.warn', '/log/syslog.warn', '/log/user.warn', 278 \ '/log/auth.crit', '/log/cron.crit', '/log/daemon.crit', '/log/debug.crit', '/log/kern.crit', '/log/lpr.crit', '/log/mail.crit', '/log/messages.crit', '/log/news/news.crit', '/log/syslog.crit', '/log/user.crit', 279 \ '/log/auth.notice', '/log/cron.notice', '/log/daemon.notice', '/log/debug.notice', '/log/kern.notice', '/log/lpr.notice', '/log/mail.notice', '/log/messages.notice', '/log/news/news.notice', '/log/syslog.notice', '/log/user.notice'], 280 \ 'mf': ['file.mf'], 281 \ 'mgl': ['file.mgl'], 282 \ 'mgp': ['file.mgp'], 283 \ 'mib': ['file.mib', 'file.my'], 284 \ 'mix': ['file.mix', 'file.mixal'], 285 \ 'mma': ['file.nb'], 286 \ 'mmp': ['file.mmp'], 287 \ 'modconf': ['/etc/modules.conf', '/etc/modules', '/etc/conf.modules'], 288 \ 'modula2': ['file.m2', 'file.mi'], 289 \ 'monk': ['file.isc', 'file.monk', 'file.ssc', 'file.tsc'], 290 \ 'moo': ['file.moo'], 291 \ 'mp': ['file.mp'], 292 \ 'mplayerconf': ['mplayer.conf', '/.mplayer/config'], 293 \ 'mrxvtrc': ['mrxvtrc', '.mrxvtrc'], 294 \ 'msidl': ['file.odl', 'file.mof'], 295 \ 'msql': ['file.msql'], 296 \ 'mupad': ['file.mu'], 297 \ 'mush': ['file.mush'], 298 \ 'muttrc': ['Muttngrc', 'Muttrc'], 299 \ 'mysql': ['file.mysql'], 300 \ 'n1ql': ['file.n1ql', 'file.nql'], 301 \ 'named': ['namedfile.conf', 'rndcfile.conf'], 302 \ 'nanorc': ['/etc/nanorc', 'file.nanorc'], 303 \ 'ncf': ['file.ncf'], 304 \ 'netrc': ['.netrc'], 305 \ 'ninja': ['file.ninja'], 306 \ 'nqc': ['file.nqc'], 307 \ 'nroff': ['file.tr', 'file.nr', 'file.roff', 'file.tmac', 'file.mom'], 308 \ 'nsis': ['file.nsi', 'file.nsh'], 309 \ 'obj': ['file.obj'], 310 \ 'ocaml': ['file.ml', 'file.mli', 'file.mll', 'file.mly', '.ocamlinit'], 311 \ 'occam': ['file.occ'], 312 \ 'omnimark': ['file.xom', 'file.xin'], 313 \ 'openroad': ['file.or'], 314 \ 'ora': ['file.ora'], 315 \ 'pamconf': ['/etc/pam.conf'], 316 \ 'papp': ['file.papp', 'file.pxml', 'file.pxsl'], 317 \ 'pascal': ['file.pas', 'file.dpr'], 318 \ 'passwd': ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit', 'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit', 'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak'], 319 \ 'pccts': ['file.g'], 320 \ 'pdf': ['file.pdf'], 321 \ 'perl': ['file.plx', 'file.al', 'file.psgi', 'gitolite.rc', '.gitolite.rc', 'example.gitolite.rc'], 322 \ 'perl6': ['file.p6', 'file.pm6', 'file.pl6'], 323 \ 'pf': ['pf.conf'], 324 \ 'pfmain': ['main.cf'], 325 \ 'php': ['file.php', 'file.php9', 'file.phtml', 'file.ctp'], 326 \ 'lpc': ['file.lpc', 'file.ulpc'], 327 \ 'pike': ['file.pike', 'file.pmod'], 328 \ 'cmod': ['file.cmod'], 329 \ 'pilrc': ['file.rcp'], 330 \ 'pine': ['.pinerc', 'pinerc', '.pinercex', 'pinercex'], 331 \ 'pinfo': ['/etc/pinforc', '/.pinforc'], 332 \ 'pli': ['file.pli', 'file.pl1'], 333 \ 'plm': ['file.plm', 'file.p36', 'file.pac'], 334 \ 'plp': ['file.plp'], 335 \ 'plsql': ['file.pls', 'file.plsql'], 336 \ 'po': ['file.po', 'file.pot'], 337 \ 'pod': ['file.pod'], 338 \ 'pod6': ['file.pod6'], 339 \ 'postscr': ['file.ps', 'file.pfa', 'file.afm', 'file.eps', 'file.epsf', 'file.epsi', 'file.ai'], 340 \ 'pov': ['file.pov'], 341 \ 'povini': ['.povrayrc'], 342 \ 'ppd': ['file.ppd'], 343 \ 'ppwiz': ['file.it', 'file.ih'], 344 \ 'privoxy': ['file.action'], 345 \ 'proc': ['file.pc'], 346 \ 'procmail': ['.procmail', '.procmailrc'], 347 \ 'prolog': ['file.pdb'], 348 \ 'promela': ['file.pml'], 349 \ 'proto': ['file.proto'], 350 \ 'protocols': ['/etc/protocols'], 351 \ 'psf': ['file.psf'], 352 \ 'pyrex': ['file.pyx', 'file.pxd'], 353 \ 'python': ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi'], 354 \ 'quake': ['anybaseq2/file.cfg', 'anyid1/file.cfg', 'quake3/file.cfg'], 355 \ 'radiance': ['file.rad', 'file.mat'], 356 \ 'ratpoison': ['.ratpoisonrc', 'ratpoisonrc'], 357 \ 'rc': ['file.rc', 'file.rch'], 358 \ 'rcs': ['file,v'], 359 \ 'readline': ['.inputrc', 'inputrc'], 360 \ 'remind': ['.reminders', 'file.remind', 'file.rem'], 361 \ 'resolv': ['resolv.conf'], 362 \ 'reva': ['file.frt'], 363 \ 'rexx': ['file.rex', 'file.orx', 'file.rxo', 'file.rxj', 'file.jrexx', 'file.rexxj', 'file.rexx', 'file.testGroup', 'file.testUnit'], 364 \ 'rib': ['file.rib'], 365 \ 'rnc': ['file.rnc'], 366 \ 'rng': ['file.rng'], 367 \ 'robots': ['robots.txt'], 368 \ 'rpcgen': ['file.x'], 369 \ 'rpl': ['file.rpl'], 370 \ 'rst': ['file.rst'], 371 \ 'rtf': ['file.rtf'], 372 \ 'ruby': ['.irbrc', 'irbrc', 'file.rb', 'file.rbw', 'file.gemspec', 'file.ru', 'Gemfile', 'file.builder', 'file.rxml', 'file.rjs', 'file.rant', 'file.rake'], 373 \ 'rust': ['file.rs'], 374 \ 'samba': ['smb.conf'], 375 \ 'sas': ['file.sas'], 376 \ 'sass': ['file.sass'], 377 \ 'sather': ['file.sa'], 378 \ 'sbt': ['file.sbt'], 379 \ 'scala': ['file.scala'], 380 \ 'scheme': ['file.scm', 'file.ss', 'file.rkt'], 381 \ 'scilab': ['file.sci', 'file.sce'], 382 \ 'screen': ['.screenrc', 'screenrc'], 383 \ 'scss': ['file.scss'], 384 \ 'sd': ['file.sd'], 385 \ 'sdc': ['file.sdc'], 386 \ 'sdl': ['file.sdl', 'file.pr'], 387 \ 'sed': ['file.sed'], 388 \ 'sensors': ['/etc/sensors.conf', '/etc/sensors3.conf'], 389 \ 'services': ['/etc/services'], 390 \ 'setserial': ['/etc/serial.conf'], 391 \ 'sh': ['/etc/udev/cdsymlinks.conf'], 392 \ 'sieve': ['file.siv', 'file.sieve'], 393 \ 'simula': ['file.sim'], 394 \ 'sinda': ['file.sin', 'file.s85'], 395 \ 'sisu': ['file.sst', 'file.ssm', 'file.ssi', 'file.-sst', 'file._sst', 'file.sst.meta', 'file.-sst.meta', 'file._sst.meta'], 396 \ 'skill': ['file.il', 'file.ils', 'file.cdf'], 397 \ 'slang': ['file.sl'], 398 \ 'slice': ['file.ice'], 399 \ 'slpconf': ['/etc/slp.conf'], 400 \ 'slpreg': ['/etc/slp.reg'], 401 \ 'slpspi': ['/etc/slp.spi'], 402 \ 'slrnrc': ['.slrnrc'], 403 \ 'slrnsc': ['file.score'], 404 \ 'sm': ['sendmail.cf'], 405 \ 'smarty': ['file.tpl'], 406 \ 'smcl': ['file.hlp', 'file.ihlp', 'file.smcl'], 407 \ 'smith': ['file.smt', 'file.smith'], 408 \ 'sml': ['file.sml'], 409 \ 'snobol4': ['file.sno', 'file.spt'], 410 \ 'spec': ['file.spec'], 411 \ 'spice': ['file.sp', 'file.spice'], 412 \ 'spup': ['file.speedup', 'file.spdata', 'file.spd'], 413 \ 'spyce': ['file.spy', 'file.spi'], 414 \ 'sql': ['file.tyb', 'file.typ', 'file.tyc', 'file.pkb', 'file.pks'], 415 \ 'sqlj': ['file.sqlj'], 416 \ 'sqr': ['file.sqr', 'file.sqi'], 417 \ 'squid': ['squid.conf'], 418 \ 'srec': ['file.s19', 'file.s28', 'file.s37', 'file.mot', 'file.srec'], 419 \ 'sshconfig': ['ssh_config', '/.ssh/config'], 420 \ 'sshdconfig': ['sshd_config'], 421 \ 'st': ['file.st'], 422 \ 'stata': ['file.ado', 'file.do', 'file.imata', 'file.mata'], 423 \ 'stp': ['file.stp'], 424 \ 'sudoers': ['any/etc/sudoers', 'sudoers.tmp'], 425 \ 'svg': ['file.svg'], 426 \ 'svn': ['svn-commitfile.tmp'], 427 \ 'sysctl': ['/etc/sysctl.conf', '/etc/sysctl.d/file.conf'], 428 \ 'systemd': ['any/systemd/file.automount', 'any/systemd/file.mount', 'any/systemd/file.path', 'any/systemd/file.service', 'any/systemd/file.socket', 'any/systemd/file.swap', 'any/systemd/file.target', 'any/systemd/file.timer'], 429 \ 'systemverilog': ['file.sv', 'file.svh'], 430 \ 'tags': ['tags'], 431 \ 'tak': ['file.tak'], 432 \ 'taskdata': ['pending.data', 'completed.data', 'undo.data'], 433 \ 'taskedit': ['file.task'], 434 \ 'tcl': ['file.tcl', 'file.tk', 'file.itcl', 'file.itk', 'file.jacl'], 435 \ 'teraterm': ['file.ttl'], 436 \ 'terminfo': ['file.ti'], 437 \ 'tex': ['file.latex', 'file.sty', 'file.dtx', 'file.ltx', 'file.bbl'], 438 \ 'texinfo': ['file.texinfo', 'file.texi', 'file.txi'], 439 \ 'texmf': ['texmf.cnf'], 440 \ 'text': ['file.text', 'README'], 441 \ 'tf': ['file.tf', '.tfrc', 'tfrc'], 442 \ 'tidy': ['.tidyrc', 'tidyrc'], 443 \ 'tilde': ['file.t.html'], 444 \ 'tli': ['file.tli'], 445 \ 'tmux': ['tmuxfile.conf', '.tmuxfile.conf'], 446 \ 'tpp': ['file.tpp'], 447 \ 'treetop': ['file.treetop'], 448 \ 'trustees': ['trustees.conf'], 449 \ 'tsalt': ['file.slt'], 450 \ 'tsscl': ['file.tsscl'], 451 \ 'tssgm': ['file.tssgm'], 452 \ 'tssop': ['file.tssop'], 453 \ 'twig': ['file.twig'], 454 \ 'typescript': ['file.ts'], 455 \ 'uc': ['file.uc'], 456 \ 'udevconf': ['/etc/udev/udev.conf'], 457 \ 'udevperm': ['/etc/udev/permissions.d/file.permissions'], 458 \ 'uil': ['file.uit', 'file.uil'], 459 \ 'updatedb': ['/etc/updatedb.conf'], 460 \ 'upstart': ['/usr/share/upstart/file.conf', '/usr/share/upstart/file.override', '/etc/init/file.conf', '/etc/init/file.override', '/.init/file.conf', '/.init/file.override', '/.config/upstart/file.conf', '/.config/upstart/file.override'], 461 \ 'upstreamdat': ['upstream.dat', 'UPSTREAM.DAT', 'upstream.file.dat', 'UPSTREAM.FILE.DAT', 'file.upstream.dat', 'FILE.UPSTREAM.DAT'], 462 \ 'upstreaminstalllog': ['upstreaminstall.log', 'UPSTREAMINSTALL.LOG', 'upstreaminstall.file.log', 'UPSTREAMINSTALL.FILE.LOG', 'file.upstreaminstall.log', 'FILE.UPSTREAMINSTALL.LOG'], 463 \ 'upstreamlog': ['fdrupstream.log', 'upstream.log', 'UPSTREAM.LOG', 'upstream.file.log', 'UPSTREAM.FILE.LOG', 'file.upstream.log', 'FILE.UPSTREAM.LOG', 'UPSTREAM-file.log', 'UPSTREAM-FILE.LOG'], 464 \ 'usserverlog': ['usserver.log', 'USSERVER.LOG', 'usserver.file.log', 'USSERVER.FILE.LOG', 'file.usserver.log', 'FILE.USSERVER.LOG'], 465 \ 'usw2kagtlog': ['usw2kagt.log', 'USW2KAGT.LOG', 'usw2kagt.file.log', 'USW2KAGT.FILE.LOG', 'file.usw2kagt.log', 'FILE.USW2KAGT.LOG'], 466 \ 'vb': ['file.sba', 'file.vb', 'file.vbs', 'file.dsm', 'file.ctl'], 467 \ 'vera': ['file.vr', 'file.vri', 'file.vrh'], 468 \ 'verilog': ['file.v'], 469 \ 'verilogams': ['file.va', 'file.vams'], 470 \ 'vgrindefs': ['vgrindefs'], 471 \ 'vhdl': ['file.hdl', 'file.vhd', 'file.vhdl', 'file.vbe', 'file.vst'], 472 \ 'vim': ['file.vim', 'file.vba', '.exrc', '_exrc'], 473 \ 'viminfo': ['.viminfo', '_viminfo'], 474 \ 'vmasm': ['file.mar'], 475 \ 'voscm': ['file.cm'], 476 \ 'vrml': ['file.wrl'], 477 \ 'vroom': ['file.vroom'], 478 \ 'wast': ['file.wast', 'file.wat'], 479 \ 'webmacro': ['file.wm'], 480 \ 'wget': ['.wgetrc', 'wgetrc'], 481 \ 'winbatch': ['file.wbt'], 482 \ 'wml': ['file.wml'], 483 \ 'wsml': ['file.wsml'], 484 \ 'wvdial': ['wvdial.conf', '.wvdialrc'], 485 \ 'xdefaults': ['.Xdefaults', '.Xpdefaults', '.Xresources', 'xdm-config', 'file.ad'], 486 \ 'xhtml': ['file.xhtml', 'file.xht'], 487 \ 'xinetd': ['/etc/xinetd.conf'], 488 \ 'xmath': ['file.msc', 'file.msf'], 489 \ 'xml': ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.ui', 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl'], 490 \ 'xmodmap': ['anyXmodmap'], 491 \ 'xf86conf': ['xorg.conf', 'xorg.conf-4'], 492 \ 'xpm2': ['file.xpm2'], 493 \ 'xquery': ['file.xq', 'file.xql', 'file.xqm', 'file.xquery', 'file.xqy'], 494 \ 'xs': ['file.xs'], 495 \ 'xsd': ['file.xsd'], 496 \ 'xslt': ['file.xsl', 'file.xslt'], 497 \ 'yacc': ['file.yy', 'file.yxx', 'file.y++'], 498 \ 'yaml': ['file.yaml', 'file.yml'], 499 \ 'raml': ['file.raml'], 500 \ 'z8a': ['file.z8a'], 501 \ 'zimbu': ['file.zu'], 502 \ 'zimbutempl': ['file.zut'], 503 \ 'zsh': ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh'], 504 \ 505 \ 'aap': ['file.aap'], 506 \ 'help': [$VIMRUNTIME . '/doc/help.txt'], 507 \ 'xpm': ['file.xpm'], 508 \ } 509 510let s:filename_case_checks = { 511 \ 'modula2': ['file.DEF', 'file.MOD'], 512 \ } 513 514func CheckItems(checks) 515 for [ft, names] in items(a:checks) 516 for i in range(0, len(names) - 1) 517 new 518 try 519 exe 'edit ' . names[i] 520 catch 521 call assert_report('cannot edit "' . names[i] . '": ' . v:errmsg) 522 endtry 523 if &filetype == '' && &readonly 524 " File exists but not able to edit it (permission denied) 525 else 526 call assert_equal(ft, &filetype, 'with file name: ' . names[i]) 527 endif 528 bwipe! 529 endfor 530 endfor 531endfunc 532 533func Test_filetype_detection() 534 filetype on 535 call CheckItems(s:filename_checks) 536 if has('fname_case') 537 call CheckItems(s:filename_case_checks) 538 endif 539 filetype off 540endfunc 541 542" Filetypes detected from the file contents by scripts.vim 543let s:script_checks = { 544 \ 'virata': [['% Virata'], 545 \ ['', '% Virata'], 546 \ ['', '', '% Virata'], 547 \ ['', '', '', '% Virata'], 548 \ ['', '', '', '', '% Virata']], 549 \ 'strace': [['execve("/usr/bin/pstree", ["pstree"], 0x7ff0 /* 63 vars */) = 0'], 550 \ ['15:17:47 execve("/usr/bin/pstree", ["pstree"], ... "_=/usr/bin/strace"]) = 0'], 551 \ ['__libc_start_main and something']], 552 \ 'clojure': [['#!/path/clojure']], 553 \ 'scala': [['#!/path/scala']], 554 \ 'tcsh': [['#!/path/tcsh']], 555 \ 'zsh': [['#!/path/zsh']], 556 \ 'tcl': [['#!/path/tclsh'], 557 \ ['#!/path/wish'], 558 \ ['#!/path/expectk'], 559 \ ['#!/path/itclsh'], 560 \ ['#!/path/itkwish']], 561 \ 'expect': [['#!/path/expect']], 562 \ 'gnuplot': [['#!/path/gnuplot']], 563 \ 'make': [['#!/path/make']], 564 \ 'pike': [['#!/path/pike'], 565 \ ['#!/path/pike0'], 566 \ ['#!/path/pike9']], 567 \ 'lua': [['#!/path/lua']], 568 \ 'perl6': [['#!/path/perl6']], 569 \ 'perl': [['#!/path/perl']], 570 \ 'php': [['#!/path/php']], 571 \ 'python': [['#!/path/python'], 572 \ ['#!/path/python2'], 573 \ ['#!/path/python3']], 574 \ 'groovy': [['#!/path/groovy']], 575 \ 'ruby': [['#!/path/ruby']], 576 \ 'javascript': [['#!/path/node'], 577 \ ['#!/path/js'], 578 \ ['#!/path/nodejs'], 579 \ ['#!/path/rhino']], 580 \ 'bc': [['#!/path/bc']], 581 \ 'sed': [['#!/path/sed']], 582 \ 'ocaml': [['#!/path/ocaml']], 583 \ 'awk': [['#!/path/awk']], 584 \ 'wml': [['#!/path/wml']], 585 \ 'scheme': [['#!/path/scheme']], 586 \ 'cfengine': [['#!/path/cfengine']], 587 \ 'erlang': [['#!/path/escript']], 588 \ 'haskell': [['#!/path/haskell']], 589 \ 'cpp': [['// Standard iostream objects -*- C++ -*-'], 590 \ ['// -*- C++ -*-']], 591 \ } 592 593func Test_script_detection() 594 filetype on 595 for [ft, files] in items(s:script_checks) 596 for file in files 597 call writefile(file, 'Xtest') 598 split Xtest 599 call assert_equal(ft, &filetype, 'for text: ' . string(file)) 600 bwipe! 601 endfor 602 endfor 603 call delete('Xtest') 604 filetype off 605endfunc 606 607func Test_setfiletype_completion() 608 call feedkeys(":setfiletype java\<C-A>\<C-B>\"\<CR>", 'tx') 609 call assert_equal('"setfiletype java javacc javascript', @:) 610endfunc 611