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

77099ed6b3

Co-authored-by: Gareth Lloyd <gareth@ignition-web.co.uk>
This commit is contained in:
zeertzjq
2026-06-22 09:09:13 +08:00
parent 5999f64c48
commit 19446ec9cb
2 changed files with 13 additions and 0 deletions

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"