aboutsummaryrefslogtreecommitdiff
path: root/runtime/syntax/cpp.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2026-01-09 09:39:29 +0800
committerzeertzjq <zeertzjq@outlook.com>2026-01-09 09:39:35 +0800
commitaf7925ec58f43065aa8d2de089618bc755757120 (patch)
treead39e03501b533d1887d91a3e751fe6c3e9ae4cc /runtime/syntax/cpp.vim
parent9ca69488cf08d78609ad4baef50bbcbbc937a9b7 (diff)
downloadrneovim-af7925ec58f43065aa8d2de089618bc755757120.tar.gz
rneovim-af7925ec58f43065aa8d2de089618bc755757120.tar.bz2
rneovim-af7925ec58f43065aa8d2de089618bc755757120.zip
vim-patch:335aecd: runtime(cpp): Fix c++ float and integer literal syntax highlighting
closes: vim/vim#8939 https://github.com/vim/vim/commit/335aecd98f75a081ad34b99e34922f3e7e0b25ea Co-authored-by: Dominique Pelle <dominique.pelle@gmail.com> Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Diffstat (limited to 'runtime/syntax/cpp.vim')
-rw-r--r--runtime/syntax/cpp.vim23
1 files changed, 12 insertions, 11 deletions
diff --git a/runtime/syntax/cpp.vim b/runtime/syntax/cpp.vim
index 2bf5b1ffc4..5ea52ec502 100644
--- a/runtime/syntax/cpp.vim
+++ b/runtime/syntax/cpp.vim
@@ -4,8 +4,9 @@
" Previous Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
" Ken Shan <ccshan@post.harvard.edu>
" Last Change: 2024 May 04
-" 2024 May 04 by Vim Project (fix digit separator in octals and floats)
-" 2026 Jan 06 by Vim Project (announce adoption)
+" 2024 May 04 by Vim Project fix digit separator in octals and floats
+" 2026 Jan 06 by Vim Project orphaning announcement
+" 2026 Jan 08 by Vim Project highlight capital letter prefixes for numbers
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -59,11 +60,11 @@ if !exists("cpp_no_cpp14")
syn match cppNumber display contained "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
syn match cppNumber display contained "\<0\('\=\o\+\)\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
- syn match cppNumber display contained "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
- syn match cppNumber display contained "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
- syn match cppFloat display contained "\<\d\('\=\d\+\)*\.\(\d\('\=\d\+\)*\)\=\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
- syn match cppFloat display contained "\.\d\('\=\d\+\)*\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
- syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+ syn match cppNumber display contained "\<0[Bb][01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+ syn match cppNumber display contained "\<0[Xx]\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+ syn match cppFloat display contained "\<\d\('\=\d\+\)*\.\(\d\('\=\d\+\)*\)\=\([Ee][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+ syn match cppFloat display contained "\.\d\('\=\d\+\)*\([Ee][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+ syn match cppFloat display contained "\<\d\+[Ee][-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
syn region cppString start=+\(L\|u\|u8\|U\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell
endif
@@ -71,8 +72,8 @@ endif
if !exists("cpp_no_cpp17")
syn match cppCast "\<reinterpret_pointer_cast\s*<"me=e-1
syn match cppCast "\<reinterpret_pointer_cast\s*$"
- syn match cppFloat display contained "\<0x\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
- syn match cppFloat display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+ syn match cppFloat display contained "\<0[Xx]\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+ syn match cppFloat display contained "\<0[Xx]\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
" TODO: push this up to c.vim if/when supported in C23
syn match cppCharacter "u8'[^\\]'"
@@ -94,8 +95,8 @@ if !exists("cpp_no_cpp20")
syn match cppNumber display contained "\<0\(y\|d\)\>"
syn match cppNumber display contained "\<[1-9]\('\=\d\+\)*\(y\|d\)\>"
syn match cppNumber display contained "\<0\o\+\(y\|d\)\>"
- syn match cppNumber display contained "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>"
- syn match cppNumber display contained "\<0x\x\('\=\x\+\)*\(y\|d\)\>"
+ syn match cppNumber display contained "\<0[Bb][01]\('\=[01]\+\)*\(y\|d\)\>"
+ syn match cppNumber display contained "\<0[Xx]\x\('\=\x\+\)*\(y\|d\)\>"
syn keyword cppStatement co_await co_return co_yield requires
syn keyword cppStorageClass consteval constinit
syn keyword cppStructure concept