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