8000 Add C++ syntax support for user-defined literals · adah1972/vim-cpp@502a16b · GitHub
[go: up one dir, main page]

Skip to content

Commit 502a16b

Browse files
committed
Add C++ syntax support for user-defined literals
1 parent 5df5e05 commit 502a16b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

syntax/cpp.vim

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
" Language: C++
33
" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
44
" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
5-
" Last Change: 2021 Jan 12
5+
" Last Change: 2021 Apr 12
66

77
" quit when a syntax file was already loaded
88
if exists("b:current_syntax")
@@ -44,22 +44,29 @@ if !exists("cpp_no_cpp11")
4444
syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE
4545
syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE
4646
syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE
47-
syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell
47+
syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ contains=@Spell
4848
syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*<"me=e-1
4949
syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*$"
5050
endif
5151

5252
" C++ 14 extensions
5353
if !exists("cpp_no_cpp14")
5454
syn case ignore
55-
syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
56-
syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" contains=cFloat
57-
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
55+
syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>"
56+
syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>"
57+
syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>"
58+
syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>"
59+
syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" contains=cppFloat
60+
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>"
61+
syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ end='$' contains=cSpecial,cFormat,@Spell
5862
syn case match
5963
endif
6064

6165
" C++ 20 extensions
6266
if !exists("cpp_no_cpp20")
67+
syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>"
68+
syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(y\|d\)\>"
69+
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(y\|d\)\>"
6370
syn keyword cppStatement co_await co_return co_yield requires
6471
syn keyword cppStorageClass consteval constinit
6572
syn keyword cppStructure concept
@@ -90,7 +97,9 @@ hi def link cppBoolean Boolean
9097
hi def link cppConstant Constant
9198
hi def link cppRawStringDelimiter Delimiter
9299
hi def link cppRawString String
100+
hi def link cppString String
93101
hi def link cppNumber Number
102+
hi def link cppFloat Number
94103
hi def link cppModule Include
95104

96105
let b:current_syntax = "cpp"

0 commit comments

Comments
 (0)
0