mirror of
https://github.com/neovim/neovim.git
synced 2026-07-26 02:32:02 +00:00
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:
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user