blob: ced4c239b5827cbe134efffa9967f559a1f33e72 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim support file to detect file types in scripts
2"
Christian Brabandte978b452023-08-13 10:33:05 +02003" Maintainer: The Vim Project <https://github.com/vim/vim>
4" Last Change: 2023 Aug 10
5" Former Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7" This file is called by an autocommand for every file that has just been
8" loaded into a buffer. It checks if the type of file can be recognized by
9" the file contents. The autocommand is in $VIMRUNTIME/filetype.vim.
Bram Moolenaar3a429ef2017-06-11 17:10:32 +020010"
11" Note that the pattern matches are done with =~# to avoid the value of the
12" 'ignorecase' option making a difference. Where case is to be ignored use
13" =~? instead. Do not use =~ anywhere.
Bram Moolenaar071d4272004-06-13 20:20:40 +000014
15
Bram Moolenaar299d8e52022-02-13 20:32:02 +000016" Bail out when a FileType autocommand has already set the filetype.
Bram Moolenaar071d4272004-06-13 20:20:40 +000017if did_filetype()
18 finish
19endif
20
21" Load the user defined scripts file first
22" Only do this when the FileType autocommand has not been triggered yet
Bram Moolenaarf4630b62005-05-20 21:31:17 +000023if exists("myscriptsfile") && filereadable(expand(myscriptsfile))
Bram Moolenaar071d4272004-06-13 20:20:40 +000024 execute "source " . myscriptsfile
25 if did_filetype()
26 finish
27 endif
28endif
29
Bram Moolenaar299d8e52022-02-13 20:32:02 +000030" The main code is in a compiled function for speed.
31call dist#script#DetectFiletype()