blob: 135b8c9244ffd2f4ab8ee004a442fd1ae5102b4d [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: C++
Bram Moolenaard8b77f72015-03-05 21:21:19 +01003" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
Bram Moolenaarac7bd632013-03-19 11:35:58 +01004" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
Bram Moolenaarf2571c62015-06-09 19:44:55 +02005" Last Change: 2015 May 04
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
Bram Moolenaard8b77f72015-03-05 21:21:19 +010035syn keyword cppConstant __cplusplus
Bram Moolenaar071d4272004-06-13 20:20:40 +000036
Bram Moolenaarac7bd632013-03-19 11:35:58 +010037" C++ 11 extensions
38if !exists("cpp_no_cpp11")
39 syn keyword cppType override final
40 syn keyword cppExceptions noexcept
Bram Moolenaard8b77f72015-03-05 21:21:19 +010041 syn keyword cppStorageClass constexpr decltype thread_local
Bram Moolenaarac7bd632013-03-19 11:35:58 +010042 syn keyword cppConstant nullptr
Bram Moolenaard8b77f72015-03-05 21:21:19 +010043 syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT
44 syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE
45 syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE
46 syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE
47 syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE
48 syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE
Bram Moolenaarf2571c62015-06-09 19:44:55 +020049 syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell
Bram Moolenaarac7bd632013-03-19 11:35:58 +010050endif
51
Bram Moolenaar071d4272004-06-13 20:20:40 +000052" The minimum and maximum operators in GNU C++
53syn match cppMinMax "[<>]?"
54
55" Default highlighting
56if version >= 508 || !exists("did_cpp_syntax_inits")
57 if version < 508
58 let did_cpp_syntax_inits = 1
59 command -nargs=+ HiLink hi link <args>
60 else
61 command -nargs=+ HiLink hi def link <args>
62 endif
63 HiLink cppAccess cppStatement
64 HiLink cppCast cppStatement
65 HiLink cppExceptions Exception
66 HiLink cppOperator Operator
67 HiLink cppStatement Statement
68 HiLink cppType Type
69 HiLink cppStorageClass StorageClass
70 HiLink cppStructure Structure
Bram Moolenaar071d4272004-06-13 20:20:40 +000071 HiLink cppBoolean Boolean
Bram Moolenaarac7bd632013-03-19 11:35:58 +010072 HiLink cppConstant Constant
Bram Moolenaarf2571c62015-06-09 19:44:55 +020073 HiLink cppRawStringDelimiter Delimiter
Bram Moolenaar13600302014-05-22 18:26:40 +020074 HiLink cppRawString String
Bram Moolenaar071d4272004-06-13 20:20:40 +000075 delcommand HiLink
76endif
77
78let b:current_syntax = "cpp"
79
80" vim: ts=8