blob: 04fc73342cdca9307510949955761a26ef6c7f6c [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: C++
Bram Moolenaarac7bd632013-03-19 11:35:58 +01003" Current Maintainer: vim-jp (https://github.com/vim-jp/cpp-vim)
4" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
Bram Moolenaar13600302014-05-22 18:26:40 +02005" Last Change: 2014 May 14
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7" For version 5.x: Clear all syntax items
8" For version 6.x: Quit when a syntax file was already loaded
9if version < 600
10 syntax clear
11elseif exists("b:current_syntax")
12 finish
13endif
14
15" Read the C syntax to start with
16if version < 600
17 so <sfile>:p:h/c.vim
18else
19 runtime! syntax/c.vim
20 unlet b:current_syntax
21endif
22
Bram Moolenaarac7bd632013-03-19 11:35:58 +010023" C++ extensions
Bram Moolenaar071d4272004-06-13 20:20:40 +000024syn keyword cppStatement new delete this friend using
25syn keyword cppAccess public protected private
26syn keyword cppType inline virtual explicit export bool wchar_t
27syn keyword cppExceptions throw try catch
28syn keyword cppOperator operator typeid
29syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq
30syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1
31syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$"
32syn keyword cppStorageClass mutable
33syn keyword cppStructure class typename template namespace
Bram Moolenaar071d4272004-06-13 20:20:40 +000034syn keyword cppBoolean true false
35
Bram Moolenaarac7bd632013-03-19 11:35:58 +010036" C++ 11 extensions
37if !exists("cpp_no_cpp11")
38 syn keyword cppType override final
39 syn keyword cppExceptions noexcept
40 syn keyword cppStorageClass constexpr decltype
41 syn keyword cppConstant nullptr
Bram Moolenaar13600302014-05-22 18:26:40 +020042 syn region cppRawString matchgroup=cppRawDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell
Bram Moolenaarac7bd632013-03-19 11:35:58 +010043endif
44
Bram Moolenaar071d4272004-06-13 20:20:40 +000045" The minimum and maximum operators in GNU C++
46syn match cppMinMax "[<>]?"
47
48" Default highlighting
49if version >= 508 || !exists("did_cpp_syntax_inits")
50 if version < 508
51 let did_cpp_syntax_inits = 1
52 command -nargs=+ HiLink hi link <args>
53 else
54 command -nargs=+ HiLink hi def link <args>
55 endif
56 HiLink cppAccess cppStatement
57 HiLink cppCast cppStatement
58 HiLink cppExceptions Exception
59 HiLink cppOperator Operator
60 HiLink cppStatement Statement
61 HiLink cppType Type
62 HiLink cppStorageClass StorageClass
63 HiLink cppStructure Structure
Bram Moolenaar071d4272004-06-13 20:20:40 +000064 HiLink cppBoolean Boolean
Bram Moolenaarac7bd632013-03-19 11:35:58 +010065 HiLink cppConstant Constant
Bram Moolenaar13600302014-05-22 18:26:40 +020066 HiLink cppRawDelimiter Delimiter
67 HiLink cppRawString String
Bram Moolenaar071d4272004-06-13 20:20:40 +000068 delcommand HiLink
69endif
70
71let b:current_syntax = "cpp"
72
73" vim: ts=8