blob: 06b8d8f11faf5fa032a88e502408669ed40cb867 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax support file
Christian Brabandte978b452023-08-13 10:33:05 +02002" Maintainer: The Vim Project <https://github.com/vim/vim>
3" Last Change: 2023 Aug 10
4" Former Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00005
6" This file is used for ":syntax on".
7" It installs the autocommands and starts highlighting for all buffers.
8
9if !has("syntax")
10 finish
11endif
12
13" If Syntax highlighting appears to be on already, turn it off first, so that
14" any leftovers are cleared.
15if exists("syntax_on") || exists("syntax_manual")
16 so <sfile>:p:h/nosyntax.vim
17endif
18
19" Load the Syntax autocommands and set the default methods for highlighting.
20runtime syntax/synload.vim
21
22" Load the FileType autocommands if not done yet.
23if exists("did_load_filetypes")
24 let s:did_ft = 1
25else
26 filetype on
27 let s:did_ft = 0
28endif
29
30" Set up the connection between FileType and Syntax autocommands.
31" This makes the syntax automatically set when the file type is detected.
Bram Moolenaar60895f32022-04-12 14:23:19 +010032" Avoid an error when 'verbose' is set and <amatch> expansion fails.
Bram Moolenaar071d4272004-06-13 20:20:40 +000033augroup syntaxset
Bram Moolenaar60895f32022-04-12 14:23:19 +010034 au! FileType * 0verbose exe "set syntax=" . expand("<amatch>")
Bram Moolenaar071d4272004-06-13 20:20:40 +000035augroup END
36
37
38" Execute the syntax autocommands for the each buffer.
39" If the filetype wasn't detected yet, do that now.
40" Always do the syntaxset autocommands, for buffers where the 'filetype'
41" already was set manually (e.g., help buffers).
42doautoall syntaxset FileType
43if !s:did_ft
44 doautoall filetypedetect BufRead
45endif