Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim support file to detect file types in scripts |
| 2 | " |
Christian Brabandt | e978b45 | 2023-08-13 10:33:05 +0200 | [diff] [blame] | 3 | " Maintainer: The Vim Project <https://github.com/vim/vim> |
dkearns | 73aba18 | 2023-08-28 03:47:29 +1000 | [diff] [blame] | 4 | " Last Change: 2023 Aug 27 |
Christian Brabandt | e978b45 | 2023-08-13 10:33:05 +0200 | [diff] [blame] | 5 | " Former Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6 | |
| 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. |
| 10 | |
| 11 | |
Bram Moolenaar | 299d8e5 | 2022-02-13 20:32:02 +0000 | [diff] [blame] | 12 | " Bail out when a FileType autocommand has already set the filetype. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 13 | if did_filetype() |
| 14 | finish |
| 15 | endif |
| 16 | |
| 17 | " Load the user defined scripts file first |
| 18 | " Only do this when the FileType autocommand has not been triggered yet |
Bram Moolenaar | f4630b6 | 2005-05-20 21:31:17 +0000 | [diff] [blame] | 19 | if exists("myscriptsfile") && filereadable(expand(myscriptsfile)) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 20 | execute "source " . myscriptsfile |
| 21 | if did_filetype() |
| 22 | finish |
| 23 | endif |
| 24 | endif |
| 25 | |
Bram Moolenaar | 299d8e5 | 2022-02-13 20:32:02 +0000 | [diff] [blame] | 26 | " The main code is in a compiled function for speed. |
| 27 | call dist#script#DetectFiletype() |