blob: fefd0ff7b0980330a233dae510867726f8bf1fac [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 Moolenaar063b9d12016-07-09 20:21:48 +02005" Last Change: 2016 Jul 07
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
Bram Moolenaarb4ff5182015-11-10 21:15:48 +010026syn keyword cppModifier inline virtual explicit export
27syn keyword cppType bool wchar_t
Bram Moolenaar071d4272004-06-13 20:20:40 +000028syn keyword cppExceptions throw try catch
29syn keyword cppOperator operator typeid
30syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq
31syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*<"me=e-1
32syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$"
33syn keyword cppStorageClass mutable
34syn keyword cppStructure class typename template namespace
Bram Moolenaar071d4272004-06-13 20:20:40 +000035syn keyword cppBoolean true false
Bram Moolenaard8b77f72015-03-05 21:21:19 +010036syn keyword cppConstant __cplusplus
Bram Moolenaar071d4272004-06-13 20:20:40 +000037
Bram Moolenaarac7bd632013-03-19 11:35:58 +010038" C++ 11 extensions
39if !exists("cpp_no_cpp11")
Bram Moolenaarb4ff5182015-11-10 21:15:48 +010040 syn keyword cppModifier override final
41 syn keyword cppType nullptr_t
Bram Moolenaarac7bd632013-03-19 11:35:58 +010042 syn keyword cppExceptions noexcept
Bram Moolenaard8b77f72015-03-05 21:21:19 +010043 syn keyword cppStorageClass constexpr decltype thread_local
Bram Moolenaarac7bd632013-03-19 11:35:58 +010044 syn keyword cppConstant nullptr
Bram Moolenaard8b77f72015-03-05 21:21:19 +010045 syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT
46 syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE
47 syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE
48 syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE
49 syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE
50 syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE
Bram Moolenaarf2571c62015-06-09 19:44:55 +020051 syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell
Bram Moolenaarac7bd632013-03-19 11:35:58 +010052endif
53
Bram Moolenaarb4ff5182015-11-10 21:15:48 +010054" C++ 14 extensions
55if !exists("cpp_no_cpp14")
56 syn match cppNumber display "\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>"
57endif
58
Bram Moolenaar071d4272004-06-13 20:20:40 +000059" The minimum and maximum operators in GNU C++
60syn match cppMinMax "[<>]?"
61
62" Default highlighting
63if version >= 508 || !exists("did_cpp_syntax_inits")
64 if version < 508
65 let did_cpp_syntax_inits = 1
66 command -nargs=+ HiLink hi link <args>
67 else
68 command -nargs=+ HiLink hi def link <args>
69 endif
70 HiLink cppAccess cppStatement
71 HiLink cppCast cppStatement
72 HiLink cppExceptions Exception
73 HiLink cppOperator Operator
74 HiLink cppStatement Statement
Bram Moolenaarb4ff5182015-11-10 21:15:48 +010075 HiLink cppModifier Type
Bram Moolenaar071d4272004-06-13 20:20:40 +000076 HiLink cppType Type
77 HiLink cppStorageClass StorageClass
78 HiLink cppStructure Structure
Bram Moolenaar071d4272004-06-13 20:20:40 +000079 HiLink cppBoolean Boolean
Bram Moolenaarac7bd632013-03-19 11:35:58 +010080 HiLink cppConstant Constant
Bram Moolenaarf2571c62015-06-09 19:44:55 +020081 HiLink cppRawStringDelimiter Delimiter
Bram Moolenaar13600302014-05-22 18:26:40 +020082 HiLink cppRawString String
Bram Moolenaar063b9d12016-07-09 20:21:48 +020083 HiLink cppNumber Number
Bram Moolenaar071d4272004-06-13 20:20:40 +000084 delcommand HiLink
85endif
86
87let b:current_syntax = "cpp"
88
89" vim: ts=8