blob: 185f1676d3604398ee96e1078a7d31e523698b7e [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim support file to detect file types in scripts
2"
3" Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar10e8ff92023-06-10 21:40:39 +01004" Last change: 2023 Jun 08
Bram Moolenaar071d4272004-06-13 20:20:40 +00005
6" This file is called by an autocommand for every file that has just been
7" loaded into a buffer. It checks if the type of file can be recognized by
8" the file contents. The autocommand is in $VIMRUNTIME/filetype.vim.
Bram Moolenaar3a429ef2017-06-11 17:10:32 +02009"
10" Note that the pattern matches are done with =~# to avoid the value of the
11" 'ignorecase' option making a difference. Where case is to be ignored use
12" =~? instead. Do not use =~ anywhere.
Bram Moolenaar071d4272004-06-13 20:20:40 +000013
14
Bram Moolenaar299d8e52022-02-13 20:32:02 +000015" Bail out when a FileType autocommand has already set the filetype.
Bram Moolenaar071d4272004-06-13 20:20:40 +000016if did_filetype()
17 finish
18endif
19
20" Load the user defined scripts file first
21" Only do this when the FileType autocommand has not been triggered yet
Bram Moolenaarf4630b62005-05-20 21:31:17 +000022if exists("myscriptsfile") && filereadable(expand(myscriptsfile))
Bram Moolenaar071d4272004-06-13 20:20:40 +000023 execute "source " . myscriptsfile
24 if did_filetype()
25 finish
26 endif
27endif
28
Bram Moolenaar299d8e52022-02-13 20:32:02 +000029" The main code is in a compiled function for speed.
30call dist#script#DetectFiletype()