Add new C++ feature to syntax highlighting
This commit is contained in:
parent
6cc8627c97
commit
eabffa9354
@ -37,6 +37,9 @@ syn keyword cppConstant __cplusplus
|
|||||||
|
|
||||||
" C++11
|
" C++11
|
||||||
if !exists('cpp_no_cpp11')
|
if !exists('cpp_no_cpp11')
|
||||||
|
" Identifiers with special meaning: override final
|
||||||
|
" TODO: These should not be keyword's, instead highlight based on context
|
||||||
|
" since these can be used as regular identifiers outside of those contexts.
|
||||||
syn keyword cppModifier override final
|
syn keyword cppModifier override final
|
||||||
syn keyword cppType char16_t char32_t nullptr_t
|
syn keyword cppType char16_t char32_t nullptr_t
|
||||||
syn keyword cppExceptions noexcept
|
syn keyword cppExceptions noexcept
|
||||||
@ -51,11 +54,55 @@ if !exists('cpp_no_cpp11')
|
|||||||
" however if the match starts before the beginning of the keyword it will be
|
" however if the match starts before the beginning of the keyword it will be
|
||||||
" chosen instead so we can specialze for this case.
|
" chosen instead so we can specialze for this case.
|
||||||
syn match cppStatement '=\s*\(delete\|default\)\>\ze\s*;\?' contains=cOperator display
|
syn match cppStatement '=\s*\(delete\|default\)\>\ze\s*;\?' contains=cOperator display
|
||||||
|
|
||||||
|
" Attribute Specifier Sequence
|
||||||
|
" Match: [[attribute-list]]
|
||||||
|
syn region cppAttributeDelimiter matchgroup=cppDelimiter start='\[\[' skip='\[\[' end='\]\]' transparent contains=cppAttribute,cppNamespace,cppAttributeUsing,cppAttributeUsingNamespace,cDelimiter,cString,cOperator,cNumber,cppFunction,cFunction
|
||||||
|
|
||||||
|
" Standard Attributes
|
||||||
|
syn keyword cppAttribute noreturn carries_dependency contained
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" C++14
|
" C++14
|
||||||
if !exists('cpp_no_cpp14')
|
if !exists('cpp_no_cpp14')
|
||||||
syn match cppNumber display '\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>'
|
syn match cppNumber display '\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>'
|
||||||
|
" Standard Attributes
|
||||||
|
syn keyword cppAttribute deprecated contained
|
||||||
|
endif
|
||||||
|
|
||||||
|
" C++17
|
||||||
|
if !exists('cpp_no_cpp17')
|
||||||
|
" Attribute Specifier Sequence
|
||||||
|
" Match: [[using attribute-namespace: attribute-list]]
|
||||||
|
syn match cppAttributeUsingNamespace '\s\+\zs\w\+\ze\s*:' contained contains=cppAttributeUsing
|
||||||
|
syn keyword cppAttributeUsing using contained
|
||||||
|
|
||||||
|
" Standard Attributes
|
||||||
|
syn keyword cppAttribute fallthrough nodiscard maybe_unused contained
|
||||||
|
|
||||||
|
hi def link cppAttributeUsing cppStatement
|
||||||
|
hi def link cppAttributeUsingNamespace cInclude
|
||||||
|
hi def link cppAttributeUsingDelimiter cppDelimiter
|
||||||
|
endif
|
||||||
|
|
||||||
|
" C++20
|
||||||
|
if !exists('cpp_no_cpp20')
|
||||||
|
syn keyword cppStatement concept requires
|
||||||
|
|
||||||
|
" TODO: Attribute Specifier Sequence
|
||||||
|
" Match: [[contract-attribute-token contract-level(opt) identifier(opt): expression]]
|
||||||
|
"
|
||||||
|
" Standard Attributes
|
||||||
|
syn keyword cppAttribute likely unlikely no_unique_address contained
|
||||||
|
syn keyword cppAttribute expects ensures assert contained
|
||||||
|
|
||||||
|
" Contract Levels
|
||||||
|
syn keyword cppAttribute default audit axiom contained
|
||||||
|
"
|
||||||
|
" TODO: These should not be keyword's, instead highlight based on context
|
||||||
|
" since these can be used as regular identifiers outside of those contexts.
|
||||||
|
" These only occur inside an contracts generalised attribute.
|
||||||
|
syn keyword cppModifier audit axiom
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists('cpp_no_function')
|
if !exists('cpp_no_function')
|
||||||
@ -73,14 +120,14 @@ if !exists('cpp_no_delimiters')
|
|||||||
|
|
||||||
" Match: nested namespace expressions: expr::
|
" Match: nested namespace expressions: expr::
|
||||||
" ^^^^
|
" ^^^^
|
||||||
syn match cppNestedName '\w\+::' display contains=cppDelimiter
|
syn match cppNamespace '\w\+::' display contains=cppDelimiter
|
||||||
|
|
||||||
" Match: label: as a Label and public: protected: private: as a Statement
|
" Match: label: as a Label and public: protected: private: as a Statement
|
||||||
" ^^^^^ ^^^^^^ ^^^^^^^^^ ^^^^^^^
|
" ^^^^^ ^^^^^^ ^^^^^^^^^ ^^^^^^^
|
||||||
syn match cUserCont "^\s*\I\i*\s*:$" contains=cUserLabel,cppAccess display
|
syn match cUserCont "^\s*\I\i*\s*:$" contains=cUserLabel,cppAccess display
|
||||||
|
|
||||||
hi default link cppDelimiter cDelimiter
|
hi default link cppDelimiter cDelimiter
|
||||||
hi default link cppNestedName cInclude
|
hi default link cppNamespace cInclude
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !exists('cpp_no_operators') && !exists('cpp_no_delimiters')
|
if !exists('cpp_no_operators') && !exists('cpp_no_delimiters')
|
||||||
@ -114,5 +161,6 @@ hi def link cppConstant Constant
|
|||||||
hi def link cppRawStringDelimiter Delimiter
|
hi def link cppRawStringDelimiter Delimiter
|
||||||
hi def link cppRawString String
|
hi def link cppRawString String
|
||||||
hi def link cppNumber Number
|
hi def link cppNumber Number
|
||||||
|
hi def link cppAttribute Keyword
|
||||||
|
|
||||||
let b:current_syntax = 'cpp'
|
let b:current_syntax = 'cpp'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user