blob: 553e8b209e529c4d0a80251d9cb69b37254785d2 [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 sets up for syntax highlighting.
7" It is loaded from "syntax.vim" and "manual.vim".
8" 1. Set the default highlight groups.
9" 2. Install Syntax autocommands for all the available syntax files.
10
11if !has("syntax")
12 finish
13endif
14
15" let others know that syntax has been switched on
16let syntax_on = 1
17
18" Set the default highlighting colors. Use a color scheme if specified.
19if exists("colors_name")
20 exe "colors " . colors_name
21else
22 runtime! syntax/syncolor.vim
23endif
24
25" Line continuation is used here, remove 'C' from 'cpoptions'
26let s:cpo_save = &cpo
27set cpo&vim
28
29" First remove all old syntax autocommands.
30au! Syntax
31
32au Syntax * call s:SynSet()
33
34fun! s:SynSet()
35 " clear syntax for :set syntax=OFF and any syntax name that doesn't exist
36 syn clear
37 if exists("b:current_syntax")
38 unlet b:current_syntax
39 endif
40
Bram Moolenaar60895f32022-04-12 14:23:19 +010041 0verbose let s = expand("<amatch>")
Bram Moolenaar071d4272004-06-13 20:20:40 +000042 if s == "ON"
43 " :set syntax=ON
44 if &filetype == ""
45 echohl ErrorMsg
46 echo "filetype unknown"
47 echohl None
48 endif
49 let s = &filetype
Bram Moolenaar97cc2382012-10-03 21:46:54 +020050 elseif s == "OFF"
51 let s = ""
Bram Moolenaar071d4272004-06-13 20:20:40 +000052 endif
53
54 if s != ""
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000055 " Load the syntax file(s). When there are several, separated by dots,
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +020056 " load each in sequence. Skip empty entries.
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000057 for name in split(s, '\.')
Bram Moolenaar2c7f8c52020-04-20 19:52:53 +020058 if !empty(name)
59 exe "runtime! syntax/" . name . ".vim syntax/" . name . "/*.vim"
60 endif
Bram Moolenaar97b2ad32006-03-18 21:40:56 +000061 endfor
Bram Moolenaar071d4272004-06-13 20:20:40 +000062 endif
63endfun
64
65
Bram Moolenaarfc39ecf2015-08-11 20:34:49 +020066" Handle adding doxygen to other languages (C, C++, C#, IDL, java, php, DataScript)
67au Syntax c,cpp,cs,idl,java,php,datascript
Bram Moolenaard4755bb2004-09-02 19:12:26 +000068 \ if (exists('b:load_doxygen_syntax') && b:load_doxygen_syntax)
69 \ || (exists('g:load_doxygen_syntax') && g:load_doxygen_syntax)
Bram Moolenaarc9b4b052006-04-30 18:54:39 +000070 \ | runtime! syntax/doxygen.vim
Bram Moolenaard4755bb2004-09-02 19:12:26 +000071 \ | endif
72
Bram Moolenaard4755bb2004-09-02 19:12:26 +000073
Bram Moolenaar071d4272004-06-13 20:20:40 +000074" Source the user-specified syntax highlighting file
Bram Moolenaar25de4c22016-11-06 14:48:06 +010075if exists("mysyntaxfile")
76 let s:fname = expand(mysyntaxfile)
77 if filereadable(s:fname)
78 execute "source " . fnameescape(s:fname)
79 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000080endif
81
82" Restore 'cpoptions'
83let &cpo = s:cpo_save
84unlet s:cpo_save