xref: /vim-8.2.3635/runtime/syntax/synload.vim (revision b1c9198a)
1" Vim syntax support file
2" Maintainer:	Bram Moolenaar <[email protected]>
3" Last Change:	2016 Nov 04
4
5" This file sets up for syntax highlighting.
6" It is loaded from "syntax.vim" and "manual.vim".
7" 1. Set the default highlight groups.
8" 2. Install Syntax autocommands for all the available syntax files.
9
10if !has("syntax")
11  finish
12endif
13
14" let others know that syntax has been switched on
15let syntax_on = 1
16
17" Set the default highlighting colors.  Use a color scheme if specified.
18if exists("colors_name")
19  exe "colors " . colors_name
20else
21  runtime! syntax/syncolor.vim
22endif
23
24" Line continuation is used here, remove 'C' from 'cpoptions'
25let s:cpo_save = &cpo
26set cpo&vim
27
28" First remove all old syntax autocommands.
29au! Syntax
30
31au Syntax *		call s:SynSet()
32
33fun! s:SynSet()
34  " clear syntax for :set syntax=OFF  and any syntax name that doesn't exist
35  syn clear
36  if exists("b:current_syntax")
37    unlet b:current_syntax
38  endif
39
40  let s = expand("<amatch>")
41  if s == "ON"
42    " :set syntax=ON
43    if &filetype == ""
44      echohl ErrorMsg
45      echo "filetype unknown"
46      echohl None
47    endif
48    let s = &filetype
49  elseif s == "OFF"
50    let s = ""
51  endif
52
53  if s != ""
54    " Load the syntax file(s).  When there are several, separated by dots,
55    " load each in sequence.
56    for name in split(s, '\.')
57      exe "runtime! syntax/" . name . ".vim syntax/" . name . "/*.vim"
58    endfor
59  endif
60endfun
61
62
63" Handle adding doxygen to other languages (C, C++, C#, IDL, java, php, DataScript)
64au Syntax c,cpp,cs,idl,java,php,datascript
65	\ if (exists('b:load_doxygen_syntax') && b:load_doxygen_syntax)
66	\	|| (exists('g:load_doxygen_syntax') && g:load_doxygen_syntax)
67	\   | runtime! syntax/doxygen.vim
68	\ | endif
69
70
71" Source the user-specified syntax highlighting file
72if exists("mysyntaxfile")
73  let s:fname = expand(mysyntaxfile)
74  if filereadable(s:fname)
75    execute "source " . fnameescape(s:fname)
76  endif
77endif
78
79" Restore 'cpoptions'
80let &cpo = s:cpo_save
81unlet s:cpo_save
82