vim-patch:77099ed: runtime(cpp): add C++26 lexical constructs to syntax highlighting

Add a guarded "C++ 26 extensions" block (cpp_no_cpp26) covering new
lexical surface introduced since C++23:

- [[ ... ]] attributes as a region, so P3394 annotations carrying a
  value expression (eg [[=foo{1}]]) no longer trip cErrInBracket on
  their braces/parens. A \w\@1<! look-behind keeps it from matching a
  subscripted immediately-invoked lambda (arr[[]{...}()]).
- ^^ reflection operator (P2996).
- [: :] splice brackets (P2996).
- contract_assert keyword (P2900).

Add input/cpp_cpp26.cpp exercising these constructs with screendumps,
and update dumps/cpp_noreturn_00.dump for the new [[ ]] attribute
delimiter highlighting.

closes: vim/vim#20577

https://github.com/vim/vim/commit/77099ed6b3b35b6340fd4945ba219020034a9182

Co-authored-by: Gareth Lloyd <gareth@ignition-web.co.uk>
This commit is contained in:
zeertzjqandGareth Lloyd committed 2026-06-22 09:51:52 +08:00
1 parent 5999f64c48
commit 19446ec9cb
2 files changed
+13

No files matched your search

+1
View File
@@ -777,6 +777,7 @@ cpp_no_cpp14 don't highlight C++14 standard items
cpp_no_cpp17 don't highlight C++17 standard items
cpp_no_cpp20 don't highlight C++20 standard items
cpp_no_cpp23 don't highlight C++23 standard items
cpp_no_cpp26 don't highlight C++26 standard items
CSH *ft-csh-syntax*
+12
View File
@@ -110,6 +110,15 @@ if !exists("cpp_no_cpp23")
syn keyword cppType float16_t float32_t float64_t float128_t bfloat16_t
endif
" C++ 26 extensions
if !exists("cpp_no_cpp26")
" attribute [[ ... ]] with optional value expr, eg [[=foo{1}]]
syn region cppAttribute matchgroup=cppAttributeBracket start="\w\@1<!\[\[" end="\]\]" contains=TOP,@Spell
syn match cppReflect "\^\^"
syn match cppSpliceBracket "\[:\|:\]"
syn keyword cppStatement contract_assert
endif
" The minimum and maximum operators in GNU C++
syn match cppMinMax "[<>]?"
@@ -134,6 +143,9 @@ hi def link cppString String
hi def link cppNumber Number
hi def link cppFloat Number
hi def link cppModule Include
hi def link cppAttributeBracket Special
hi def link cppReflect Operator
hi def link cppSpliceBracket Special
let b:current_syntax = "cpp"