From 30e318400749b55a91b8a7f8943db7afc04da447 Mon Sep 17 00:00:00 2001 From: mattn Date: Sun, 1 Mar 2015 01:51:09 +0900 Subject: [PATCH 01/41] Merge upstream --- syntax/c.vim | 68 +++++++++++++++++++++++++++++--------------------- syntax/cpp.vim | 2 +- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/syntax/c.vim b/syntax/c.vim index 09bd602..7e90360 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2013 Jul 05 +" Last Change: 2015 Mar 1 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -35,28 +35,37 @@ syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" if !exists("c_no_utf") syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)" endif -if exists("c_no_cformat") - syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend - " cCppString: same as cString, but ends at end of line - if !exists("cpp_no_cpp11") " ISO C++11 - syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell - else - syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell - endif - syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cSpaceError,cCppSkip - syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip -else + +if !exists("c_no_cformat") + " Highlight % items in strings. if !exists("c_no_c99") " ISO C99 syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained else syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained endif syn match cFormat display "%%" contained +endif + +" cCppString: same as cString, but ends at end of line +if s:ft ==# "cpp" && !exists("cpp_no_cpp11") && !exists("c_no_cformat") + " ISO C++11 + syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend + syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell +elseif s:ft ==# "c" && !exists("c_no_c11") && !exists("c_no_cformat") + " ISO C99 + syn region cString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend + syn region cCppString start=+\%(L\|U\|u8\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell +else + " older C or C++ + syn match cFormat display "%%" contained syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend - " cCppString: same as cString, but ends at end of line syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell endif +syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip + +syn cluster cStringGroup contains=cCppString,cCppSkip + syn match cCharacter "L\='[^\\]'" syn match cCharacter "L'[^']*'" contains=cSpecial if exists("c_gnu") @@ -70,7 +79,8 @@ syn match cSpecialCharacter display "L\='\\\o\{1,3}'" syn match cSpecialCharacter display "'\\x\x\{1,2}'" syn match cSpecialCharacter display "L'\\x\x\+'" -if !exists("c_no_c11") " ISO C11 +if (s:ft ==# "c" && !exists("c_no_c11")) || (s:ft ==# "cpp" && !exists("cpp_no_cpp11")) + " ISO C11 or ISO C++ 11 if exists("c_no_cformat") syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend else @@ -102,24 +112,24 @@ endif " This should be before cErrInParen to avoid problems with #define ({ xxx }) if exists("c_curly_error") syn match cCurlyError "}" - syn region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fold + syn region cBlock start="{" end="}" contains=ALLBUT,cBadBlock,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell fold else syn region cBlock start="{" end="}" transparent fold endif -"catch errors caused by wrong parenthesis and brackets -" also accept <% for {, %> for }, <: for [ and :> for ] (C99) +" Catch errors caused by wrong parenthesis and brackets. +" Also accept <% for {, %> for }, <: for [ and :> for ] (C99) " But avoid matching <::. syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom if exists("c_no_curly_error") if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell syn match cParenError display ")" syn match cErrInParen display contained "^^<%\|^%>" else - syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell + syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell syn match cParenError display ")" @@ -127,13 +137,13 @@ if exists("c_no_curly_error") endif elseif exists("c_no_bracket_error") if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell syn match cParenError display ")" syn match cErrInParen display contained "<%\|%>" else - syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@Spell + syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell syn match cParenError display ")" @@ -141,19 +151,19 @@ elseif exists("c_no_bracket_error") endif else if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell + syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell syn match cParenError display "[\])]" syn match cErrInParen display contained "<%\|%>" - syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell + syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell else - syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell + syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell syn match cParenError display "[\])]" syn match cErrInParen display contained "[\]{}]\|<%\|%>" - syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell + syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cErrInParen,cCppParen,cCppBracket,@cStringGroup,@Spell endif " cCppBracket: same as cParen but ends at end-of-line; used in cDefine syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell @@ -322,6 +332,9 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET syn keyword cConstant TMP_MAX stderr stdin stdout syn keyword cConstant EXIT_FAILURE EXIT_SUCCESS RAND_MAX + " POSIX 2001 + syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG + syn keyword cConstant SIGVTALRM SIGXCPU SIGXFSZ " Add POSIX errors as well syn keyword cConstant E2BIG EACCES EAGAIN EBADF EBADMSG EBUSY syn keyword cConstant ECANCELED ECHILD EDEADLK EDOM EEXIST EFAULT @@ -373,7 +386,7 @@ syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\> " Highlight User Labels syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString if s:ft ==# 'c' || exists("cpp_no_cpp11") - syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell + syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell,@cStringGroup endif " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' syn cluster cLabelGroup contains=cUserLabel @@ -458,8 +471,7 @@ hi def link cTodo Todo hi def link cBadContinuation Error hi def link cCppOutSkip cCppOutIf2 hi def link cCppInElse2 cCppOutIf2 -hi def link cCppOutIf2 cCppOut2 " Old syntax group for #if 0 body -hi def link cCppOut2 cCppOut " Old syntax group for #if of #if 0 +hi def link cCppOutIf2 cCppOut hi def link cCppOut Comment let b:current_syntax = "c" diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 1801004..a92d4ea 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2014 May 13 +" Last Change: 2015 Mar 1 " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded From cfd50037c8183e41a0a3a1659cad0860636b7ee8 Mon Sep 17 00:00:00 2001 From: crazymaster Date: Mon, 2 Mar 2015 07:49:31 +0900 Subject: [PATCH 02/41] Revert "merge master" This reverts commit 09f3b23458d501a39286269a18d74ec798cc6d13. Ref. #15 --- syntax/cpp.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index a92d4ea..78731d7 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -32,14 +32,21 @@ syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$" syn keyword cppStorageClass mutable syn keyword cppStructure class typename template namespace syn keyword cppBoolean true false +syn keyword cppConstant __cplusplus " C++ 11 extensions if !exists("cpp_no_cpp11") syn keyword cppType override final syn keyword cppExceptions noexcept - syn keyword cppStorageClass constexpr decltype + syn keyword cppStorageClass constexpr decltype thread_local syn keyword cppConstant nullptr - syn region cppRawString matchgroup=cppRawDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell + syn keyword cppConstant ATOMIC_FLAG_INIT ATOMIC_VAR_INIT + syn keyword cppConstant ATOMIC_BOOL_LOCK_FREE ATOMIC_CHAR_LOCK_FREE + syn keyword cppConstant ATOMIC_CHAR16_T_LOCK_FREE ATOMIC_CHAR32_T_LOCK_FREE + syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE + syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE + syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE + syn region cppRawString matchgroup=cppRawDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell endif " The minimum and maximum operators in GNU C++ From 7e8ebd3673530e86802401db12ba0648798cf83c Mon Sep 17 00:00:00 2001 From: rhysd Date: Sun, 1 Mar 2015 02:47:51 +0900 Subject: [PATCH 03/41] Add binary literal highlight --- syntax/cpp.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index a92d4ea..59da1cf 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -42,6 +42,11 @@ if !exists("cpp_no_cpp11") syn region cppRawString matchgroup=cppRawDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell endif +" C++ 14 extensions +if !exists("cpp_no_cpp14") + syn match cppNumber display "\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>" +endif + " The minimum and maximum operators in GNU C++ syn match cppMinMax "[<>]?" @@ -65,6 +70,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits") HiLink cppConstant Constant HiLink cppRawDelimiter Delimiter HiLink cppRawString String + HiLink cppNumber Number delcommand HiLink endif From 0911af4c4c2ba8b54fe1a90a36dd0a3f1341da83 Mon Sep 17 00:00:00 2001 From: Radoslaw Burny Date: Tue, 21 Apr 2015 15:55:37 +0200 Subject: [PATCH 04/41] Add "string" to cppRawDelimiter group name This change fixes handling of raw strings in matchparen - a standard plugin that highlights matching parentheses. The bug that I'm fixing manifests in the following code: foo(bar( R"( )" ) ); If you move over parens in this code in Vim, you'll see that wrong ones are highlighted. This is because matchparen uses syntax highlighting to find (and skip) string literals. To be precise, it assumes that all string literals are highlighted with a syntax group whose name contains "string". Because we used "cppRawDelimiter", which does not contain "string" in it, parens in raw string delimiters confused the matchparen algorithm. --- syntax/cpp.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 78731d7..9ef2be4 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -46,7 +46,7 @@ if !exists("cpp_no_cpp11") syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE - syn region cppRawString matchgroup=cppRawDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell + syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell endif " The minimum and maximum operators in GNU C++ @@ -70,7 +70,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits") HiLink cppStructure Structure HiLink cppBoolean Boolean HiLink cppConstant Constant - HiLink cppRawDelimiter Delimiter + HiLink cppRawStringDelimiter Delimiter HiLink cppRawString String delcommand HiLink endif From 1ed35fe8adc413dbd90709c54949d7705491309e Mon Sep 17 00:00:00 2001 From: crazymaster Date: Mon, 28 Sep 2015 00:50:50 +0900 Subject: [PATCH 05/41] Update last change --- syntax/cpp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index e794c4e..d6507f5 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2015 Mar 1 +" Last Change: 2015 Sep 23 " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded From e0d2e4e308a2d4be4723726c478bf214b867843b Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 3 Nov 2015 22:43:28 +0900 Subject: [PATCH 06/41] add nullptr_t Close #34 --- syntax/cpp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index d6507f5..e719a5e 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -36,7 +36,7 @@ syn keyword cppConstant __cplusplus " C++ 11 extensions if !exists("cpp_no_cpp11") - syn keyword cppType override final + syn keyword cppType override final nullptr_t syn keyword cppExceptions noexcept syn keyword cppStorageClass constexpr decltype thread_local syn keyword cppConstant nullptr From bc7fe9e3ead0be6a6fe3a8f2871b454051365337 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 6 Nov 2015 08:57:15 +0900 Subject: [PATCH 07/41] separate cppModifier and cppType --- syntax/cpp.vim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index e719a5e..6601612 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -23,7 +23,8 @@ endif " C++ extensions syn keyword cppStatement new delete this friend using syn keyword cppAccess public protected private -syn keyword cppType inline virtual explicit export bool wchar_t +syn keyword cppModifier inline virtual explicit export +syn keyword cppType bool wchar_t syn keyword cppExceptions throw try catch syn keyword cppOperator operator typeid syn keyword cppOperator and bitor or xor compl bitand and_eq or_eq xor_eq not not_eq @@ -36,7 +37,8 @@ syn keyword cppConstant __cplusplus " C++ 11 extensions if !exists("cpp_no_cpp11") - syn keyword cppType override final nullptr_t + syn keyword cppModifier override final + syn keyword cppType nullptr_t syn keyword cppExceptions noexcept syn keyword cppStorageClass constexpr decltype thread_local syn keyword cppConstant nullptr @@ -70,6 +72,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits") HiLink cppExceptions Exception HiLink cppOperator Operator HiLink cppStatement Statement + HiLink cppModifier Type HiLink cppType Type HiLink cppStorageClass StorageClass HiLink cppStructure Structure From dfe1c11a8a68c2f64de5ac6caa82e7b2b2e0344a Mon Sep 17 00:00:00 2001 From: h-east Date: Thu, 7 Jul 2016 12:32:54 +0900 Subject: [PATCH 08/41] Add __VA_ARGS__ as constant --- syntax/c.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/c.vim b/syntax/c.vim index 3fe3256..936c862 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -295,7 +295,7 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") syn keyword cConstant SCHAR_MIN SINT_MIN SLONG_MIN SSHRT_MIN syn keyword cConstant SCHAR_MAX SINT_MAX SLONG_MAX SSHRT_MAX if !exists("c_no_c99") - syn keyword cConstant __func__ + syn keyword cConstant __func__ __VA_ARGS__ syn keyword cConstant LLONG_MIN LLONG_MAX ULLONG_MAX syn keyword cConstant INT8_MIN INT16_MIN INT32_MIN INT64_MIN syn keyword cConstant INT8_MAX INT16_MAX INT32_MAX INT64_MAX From 9cf35d11669118941e0c2adaf8948b5329224b12 Mon Sep 17 00:00:00 2001 From: Ivan Vashchaev Date: Fri, 24 Oct 2014 23:39:10 +0400 Subject: [PATCH 09/41] dec, hex, bin literals with quote as separator --- syntax/c.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/syntax/c.vim b/syntax/c.vim index 936c862..85042e4 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -182,6 +182,11 @@ syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumbe syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" "hex number syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" +if s:ft ==# 'cpp' && !exists("cpp_no_cpp14") + syn match cNumber display contained "\d\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" + syn match cNumber display contained "0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>" + syn match cNumber display contained "0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>" +endif " Flag the first zero of an octal number as something special syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero syn match cOctalZero display contained "\<0" From 6d9f8340aea99b012b3d1b325494571b3ede8a93 Mon Sep 17 00:00:00 2001 From: Ivan Vashchaev Date: Wed, 13 Jul 2016 23:33:33 +0300 Subject: [PATCH 10/41] auto as cppType --- syntax/cpp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index aa66cef..842df74 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -37,7 +37,7 @@ syn keyword cppConstant __cplusplus " C++ 11 extensions if !exists("cpp_no_cpp11") - syn keyword cppModifier override final + syn keyword cppModifier override final auto syn keyword cppType nullptr_t syn keyword cppExceptions noexcept syn keyword cppStorageClass constexpr decltype thread_local From 86ac24ad623d33cb89e5453527ce574ad0ca05d9 Mon Sep 17 00:00:00 2001 From: Ivan Vashchaev Date: Thu, 14 Jul 2016 11:07:40 +0300 Subject: [PATCH 11/41] move 'auto' from cppModifier to cppType --- syntax/cpp.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 842df74..3109bd2 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -37,8 +37,8 @@ syn keyword cppConstant __cplusplus " C++ 11 extensions if !exists("cpp_no_cpp11") - syn keyword cppModifier override final auto - syn keyword cppType nullptr_t + syn keyword cppModifier override final + syn keyword cppType nullptr_t auto syn keyword cppExceptions noexcept syn keyword cppStorageClass constexpr decltype thread_local syn keyword cppConstant nullptr From 35926055da549efb10cd360c863eb8c2c3e2e6cb Mon Sep 17 00:00:00 2001 From: Ivan Vashchaev Date: Thu, 14 Jul 2016 11:09:30 +0300 Subject: [PATCH 12/41] remove cppNumber because C++14 int literals handled in cNumber --- syntax/cpp.vim | 6 ------ 1 file changed, 6 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 3109bd2..45d0500 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -51,11 +51,6 @@ if !exists("cpp_no_cpp11") syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell endif -" C++ 14 extensions -if !exists("cpp_no_cpp14") - syn match cppNumber display "\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>" -endif - " The minimum and maximum operators in GNU C++ syn match cppMinMax "[<>]?" @@ -80,7 +75,6 @@ if version >= 508 || !exists("did_cpp_syntax_inits") HiLink cppConstant Constant HiLink cppRawStringDelimiter Delimiter HiLink cppRawString String - HiLink cppNumber Number delcommand HiLink endif From 1a748cec31aa9ed4ad07f6580ac9d08170b6e249 Mon Sep 17 00:00:00 2001 From: Ivan Vashchaev Date: Thu, 25 Aug 2016 03:27:59 +0300 Subject: [PATCH 13/41] Move C++14 numbers to vim.cpp --- syntax/c.vim | 5 ----- syntax/cpp.vim | 10 ++++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/syntax/c.vim b/syntax/c.vim index 85042e4..936c862 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -182,11 +182,6 @@ syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumbe syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" "hex number syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" -if s:ft ==# 'cpp' && !exists("cpp_no_cpp14") - syn match cNumber display contained "\d\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" - syn match cNumber display contained "0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>" - syn match cNumber display contained "0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>" -endif " Flag the first zero of an octal number as something special syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero syn match cOctalZero display contained "\<0" diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 45d0500..cf06c77 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -51,6 +51,15 @@ if !exists("cpp_no_cpp11") syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell endif +" C++ 14 extensions +if !exists("cpp_no_cpp14") + syn case ignore + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" + syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>" + syn case match +endif + " The minimum and maximum operators in GNU C++ syn match cppMinMax "[<>]?" @@ -75,6 +84,7 @@ if version >= 508 || !exists("did_cpp_syntax_inits") HiLink cppConstant Constant HiLink cppRawStringDelimiter Delimiter HiLink cppRawString String + HiLink cppNumber Number delcommand HiLink endif From 8976dec324bdd2168f642945025a9f061644c4e3 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 28 Oct 2016 09:08:46 +0900 Subject: [PATCH 14/41] skip before #include Close #41 --- syntax/c.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/c.vim b/syntax/c.vim index 85042e4..62529f2 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -388,11 +388,11 @@ if !exists("c_no_if0") endif syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ syn match cIncluded display contained "<[^>]*>" -syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded +syn match cInclude display "\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded "syn match cLineSkip "\\$" syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock -syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell -syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell +syn region cDefine start="\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell +syn region cPreProc start="\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell " Highlight User Labels syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString From 48288357ba149f8f3770b6b6077487c214fa3d09 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 28 Oct 2016 09:11:01 +0900 Subject: [PATCH 15/41] public/private accessor break syntax See https://github.com/vim/vim/issues/1202 --- syntax/c.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/c.vim b/syntax/c.vim index 62529f2..17b01a1 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -401,8 +401,8 @@ if s:ft ==# 'c' || exists("cpp_no_cpp11") endif " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' syn cluster cLabelGroup contains=cUserLabel -syn match cUserCont display "^\s*\I\i*\s*:$" contains=@cLabelGroup -syn match cUserCont display ";\s*\I\i*\s*:$" contains=@cLabelGroup +syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup +syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup if s:ft ==# 'cpp' syn match cUserCont display "^\s*\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup syn match cUserCont display ";\s*\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup From 26079a1e58be5e08971c14f45f9f8223c72896e7 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 28 Oct 2016 09:12:42 +0900 Subject: [PATCH 16/41] update last change --- syntax/c.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/c.vim b/syntax/c.vim index 17b01a1..4b4e4e7 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2016 Apr 10 +" Last Change: 2016 Oct 28 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") From ea8ae1ae81428e83c06a894ea5c9368c77fb2f5f Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 28 Oct 2016 09:19:24 +0900 Subject: [PATCH 17/41] update last change --- syntax/cpp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index cf06c77..abf2ae0 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2015 Nov 10 +" Last Change: 2016 Oct 28 " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded From 48a135bb30f4b8b0bd2bf28deeca082b5ce2b199 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 16 Nov 2016 18:19:49 +0900 Subject: [PATCH 18/41] put \zs --- syntax/c.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/c.vim b/syntax/c.vim index 0698752..101d33a 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -367,7 +367,7 @@ if !exists("c_no_if0") if !exists("c_no_if0_fold") syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold else - syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell + syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell endif syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit syn region cCppInWrapper start="^\s*\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold From e4fadde969f7c99ee2e45013683cc2a8c93b08e9 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 16 Nov 2016 18:20:34 +0900 Subject: [PATCH 19/41] update date --- syntax/c.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/c.vim b/syntax/c.vim index 101d33a..49147db 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2016 Oct 28 +" Last Change: 2016 Nov 16 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") From 414a8ae787b1d6e4b6a5782875734c0563bd8933 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 18 Nov 2016 09:16:38 +0900 Subject: [PATCH 20/41] rebase upstream manually --- syntax/c.vim | 46 ++++++++++++++++++++++---------------------- syntax/cpp.vim | 52 +++++++++++++++++--------------------------------- 2 files changed, 41 insertions(+), 57 deletions(-) diff --git a/syntax/c.vim b/syntax/c.vim index 49147db..cc99f67 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2016 Nov 16 +" Last Change: 2016 Nov 17 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -358,36 +358,36 @@ if !exists("c_no_c99") " ISO C99 endif " Accept %: for # (C99) -syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError -syn match cPreConditMatch display "^\s*\(%:\|#\)\s*\(else\|endif\)\>" +syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError +syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>" if !exists("c_no_if0") syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip - syn region cCppOutWrapper start="^\s*\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold - syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse + syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold + syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse if !exists("c_no_if0_fold") syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell fold else - syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell + syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell endif - syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit - syn region cCppInWrapper start="^\s*\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold - syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit + syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit + syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold + syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit if !exists("c_no_if0_fold") - syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold + syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold else - syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 + syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 endif - syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell - syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip - syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc + syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell + syn region cCppOutSkip contained start="^\s*\zs\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip + syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc endif syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ syn match cIncluded display contained "<[^>]*>" -syn match cInclude display "\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded +syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded "syn match cLineSkip "\\$" syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti,cBadBlock -syn region cDefine start="\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell -syn region cPreProc start="\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell +syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell +syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell " Highlight User Labels syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString @@ -399,18 +399,18 @@ syn cluster cLabelGroup contains=cUserLabel syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup if s:ft ==# 'cpp' - syn match cUserCont display "^\s*\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup - syn match cUserCont display ";\s*\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup + syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup + syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup else - syn match cUserCont display "^\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup - syn match cUserCont display ";\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup + syn match cUserCont display "^\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup + syn match cUserCont display ";\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup endif syn match cUserLabel display "\I\i*" contained " Avoid recognizing most bitfields as labels -syn match cBitField display "^\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType -syn match cBitField display ";\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType +syn match cBitField display "^\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType +syn match cBitField display ";\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType if exists("c_minlines") let b:c_minlines = c_minlines diff --git a/syntax/cpp.vim b/syntax/cpp.vim index abf2ae0..5a478fb 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -4,21 +4,14 @@ " Previous Maintainer: Ken Shan " Last Change: 2016 Oct 28 -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists("b:current_syntax") +" quit when a syntax file was already loaded +if exists("b:current_syntax") finish endif " Read the C syntax to start with -if version < 600 - so :p:h/c.vim -else - runtime! syntax/c.vim - unlet b:current_syntax -endif +runtime! syntax/c.vim +unlet b:current_syntax " C++ extensions syn keyword cppStatement new delete this friend using @@ -64,29 +57,20 @@ endif syn match cppMinMax "[<>]?" " Default highlighting -if version >= 508 || !exists("did_cpp_syntax_inits") - if version < 508 - let did_cpp_syntax_inits = 1 - command -nargs=+ HiLink hi link - else - command -nargs=+ HiLink hi def link - endif - HiLink cppAccess cppStatement - HiLink cppCast cppStatement - HiLink cppExceptions Exception - HiLink cppOperator Operator - HiLink cppStatement Statement - HiLink cppModifier Type - HiLink cppType Type - HiLink cppStorageClass StorageClass - HiLink cppStructure Structure - HiLink cppBoolean Boolean - HiLink cppConstant Constant - HiLink cppRawStringDelimiter Delimiter - HiLink cppRawString String - HiLink cppNumber Number - delcommand HiLink -endif +hi def link cppAccess cppStatement +hi def link cppCast cppStatement +hi def link cppExceptions Exception +hi def link cppOperator Operator +hi def link cppStatement Statement +hi def link cppModifier Type +hi def link cppType Type +hi def link cppStorageClass StorageClass +hi def link cppStructure Structure +hi def link cppBoolean Boolean +hi def link cppConstant Constant +hi def link cppRawStringDelimiter Delimiter +hi def link cppRawString String +hi def link cppNumber Number let b:current_syntax = "cpp" From 66219622575ff7af14a8f74b25821c1231b7643e Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 11 May 2017 17:07:00 +0900 Subject: [PATCH 21/41] contain cFloat into cppNumber close #46, #47 --- syntax/cpp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 5a478fb..495a335 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -48,7 +48,7 @@ endif if !exists("cpp_no_cpp14") syn case ignore syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" contains=cFloat syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>" syn case match endif From 2d46cb53adc4e750d35657a6302f1e9e646d0bf0 Mon Sep 17 00:00:00 2001 From: David Briscoe Date: Fri, 16 Jun 2017 11:14:56 -0700 Subject: [PATCH 22/41] Remove date field in header Remove the "Last Change" field from cpp files. Despite multiple updates this year, both files had last changed marked as 2016. (Obviously the effort to update these files is not worth doing it. I think it's better to not be misleading.) Not changing c.vim because that date is being updated by Bram. This change was motivated by finding these files inside vim-polyglot and trying to find out where and when they're from. Better to provide less information than incorrect information. --- syntax/cpp.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 495a335..68b909b 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,6 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2016 Oct 28 " quit when a syntax file was already loaded if exists("b:current_syntax") From 9344c8e190ec3a9219b11f1559d428befcbc981f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Mon, 14 Aug 2017 19:05:10 -0700 Subject: [PATCH 23/41] add support for shared_ptr casts Note that this commit also introduces a new config variable, cpp_no_cpp17. --- syntax/cpp.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 68b909b..06fd9af 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -41,6 +41,8 @@ if !exists("cpp_no_cpp11") syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell + syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*<"me=e-1 + syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*$" endif " C++ 14 extensions @@ -52,6 +54,12 @@ if !exists("cpp_no_cpp14") syn case match endif +" C++ 17 extensions +if !exists("cpp_no_cpp17") + syn match cppCast "\]?" From a6bfc592af16e1c90ca2f445e2df8fc553265c1a Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Wed, 4 Dec 2019 10:57:49 +0100 Subject: [PATCH 24/41] Add C++20 extensions for cpp.vim --- syntax/cpp.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 68b909b..974fa17 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -52,6 +52,15 @@ if !exists("cpp_no_cpp14") syn case match endif +" C++ 20 extensions +if !exists("cpp_no_cpp20") + syn keyword cppStatement co_await co_return co_yield requires + syn keyword cppStorageClass consteval constinit + syn keyword cppStructure concept + syn keyword cppType char8_t + syn keyword cppModule import module export +endif + " The minimum and maximum operators in GNU C++ syn match cppMinMax "[<>]?" @@ -70,6 +79,7 @@ hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String hi def link cppNumber Number +hi def link cppModule Include let b:current_syntax = "cpp" From 432b2fc57e3d72e61e94830de7b4e9be35ba990c Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 17 Dec 2019 19:39:02 +0900 Subject: [PATCH 25/41] Rebase from upstream --- syntax/c.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/syntax/c.vim b/syntax/c.vim index 52193a6..79c12ab 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -382,17 +382,17 @@ if !exists("c_no_if0") else syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell endif - syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit + syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold - syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit + syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit if !exists("c_no_if0_fold") - syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold + syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold else - syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 + syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 endif - syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell - syn region cCppOutSkip contained start="^\s*\zs\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip - syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc + syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell + syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip + syn region cCppInSkip contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(if\s\+\(\d\+\s*\($\|//\|/\*\||\|&\)\)\@!\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" containedin=cCppOutElse,cCppInIf,cCppInSkip contains=TOP,cPreProc endif syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ syn match cIncluded display contained "<[^>]*>" From 0357d5d7ce9225566a8775cdbfd50131b0092e13 Mon Sep 17 00:00:00 2001 From: Stephan Beyer Date: Wed, 4 Dec 2019 10:57:49 +0100 Subject: [PATCH 26/41] Add C++20 extensions for cpp.vim --- syntax/cpp.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 9cb0860..0449c07 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -53,6 +53,15 @@ if !exists("cpp_no_cpp14") syn case match endif +" C++ 20 extensions +if !exists("cpp_no_cpp20") + syn keyword cppStatement co_await co_return co_yield requires + syn keyword cppStorageClass consteval constinit + syn keyword cppStructure concept + syn keyword cppType char8_t + syn keyword cppModule import module export +endif + " The minimum and maximum operators in GNU C++ syn match cppMinMax "[<>]?" @@ -71,6 +80,7 @@ hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String hi def link cppNumber Number +hi def link cppModule Include let b:current_syntax = "cpp" From 71c7a0683781e4397086e4fbd097632c9d090038 Mon Sep 17 00:00:00 2001 From: rgreenblatt Date: Mon, 11 Jan 2021 21:19:00 -0500 Subject: [PATCH 27/41] Check if in_cpp_family rather than just cpp, also latest c.vim --- syntax/c.vim | 28 +++++++++++++++++----------- syntax/cpp.vim | 3 +++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/syntax/c.vim b/syntax/c.vim index 79c12ab..d07aaf2 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2019 Nov 29 +" Last Change: 2021 Jan 11 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -13,6 +13,9 @@ set cpo&vim let s:ft = matchstr(&ft, '^\([^.]\)\+') +" check if this was included from cpp.vim +let s:in_cpp_family = exists("b:filetype_in_cpp_family") + " Optional embedded Autodoc parsing " To enable it add: let g:c_autodoc = 1 " to your .vimrc @@ -55,7 +58,7 @@ if !exists("c_no_cformat") endif " cCppString: same as cString, but ends at end of line -if s:ft ==# "cpp" && !exists("cpp_no_cpp11") && !exists("c_no_cformat") +if s:in_cpp_family && !exists("cpp_no_cpp11") && !exists("c_no_cformat") " ISO C++11 syn region cString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell extend syn region cCppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell @@ -87,7 +90,7 @@ syn match cSpecialCharacter display "L\='\\\o\{1,3}'" syn match cSpecialCharacter display "'\\x\x\{1,2}'" syn match cSpecialCharacter display "L'\\x\x\+'" -if (s:ft ==# "c" && !exists("c_no_c11")) || (s:ft ==# "cpp" && !exists("cpp_no_cpp11")) +if (s:ft ==# "c" && !exists("c_no_c11")) || (s:in_cpp_family && !exists("cpp_no_cpp11")) " ISO C11 or ISO C++ 11 if exists("c_no_cformat") syn region cString start=+\%(U\|u8\=\)"+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell extend @@ -130,7 +133,7 @@ endif " But avoid matching <::. syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserLabel,cBitField,cOctalZero,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom if exists("c_no_curly_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell @@ -144,7 +147,7 @@ if exists("c_no_curly_error") syn match cErrInParen display contained "^[{}]\|^<%\|^%>" endif elseif exists("c_no_bracket_error") - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell @@ -158,7 +161,7 @@ elseif exists("c_no_bracket_error") syn match cErrInParen display contained "[{}]\|<%\|%>" endif else - if s:ft ==# 'cpp' && !exists("cpp_no_cpp11") + if s:in_cpp_family && !exists("cpp_no_cpp11") syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,@cStringGroup,@Spell " cCppParen: same as cParen but ends at end-of-line; used in cDefine syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell @@ -272,12 +275,13 @@ if exists("c_gnu") syn keyword cType __label__ __complex__ __volatile__ endif -syn keyword cStructure struct union enum typedef +syn keyword cTypedef typedef +syn keyword cStructure struct union enum syn keyword cStorageClass static register auto volatile extern const if exists("c_gnu") syn keyword cStorageClass inline __attribute__ endif -if !exists("c_no_c99") && s:ft !=# 'cpp' +if !exists("c_no_c99") && !s:in_cpp_family syn keyword cStorageClass inline restrict endif if !exists("c_no_c11") @@ -311,8 +315,7 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") if exists("c_gnu") syn keyword cConstant __GNUC__ __FUNCTION__ __PRETTY_FUNCTION__ __func__ endif - syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ - syn keyword cConstant __STDC_VERSION__ + syn keyword cConstant __LINE__ __FILE__ __DATE__ __TIME__ __STDC__ __STDC_VERSION__ __STDC_HOSTED__ syn keyword cConstant CHAR_BIT MB_LEN_MAX MB_CUR_MAX syn keyword cConstant UCHAR_MAX UINT_MAX ULONG_MAX USHRT_MAX syn keyword cConstant CHAR_MIN INT_MIN LONG_MIN SHRT_MIN @@ -346,6 +349,8 @@ if !exists("c_no_ansi") || exists("c_ansi_constants") || exists("c_gnu") syn keyword cConstant SIGSTOP SIGTERM SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 syn keyword cConstant _IOFBF _IOLBF _IONBF BUFSIZ EOF WEOF FOPEN_MAX FILENAME_MAX L_tmpnam syn keyword cConstant SEEK_CUR SEEK_END SEEK_SET TMP_MAX stderr stdin stdout EXIT_FAILURE EXIT_SUCCESS RAND_MAX + " used in assert.h + syn keyword cConstant NDEBUG " POSIX 2001 syn keyword cConstant SIGBUS SIGPOLL SIGPROF SIGSYS SIGURG SIGVTALRM SIGXCPU SIGXFSZ " non-POSIX signals @@ -418,7 +423,7 @@ endif syn cluster cLabelGroup contains=cUserLabel syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup -if s:ft ==# 'cpp' +if s:in_cpp_family syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup else @@ -475,6 +480,7 @@ hi def link cSpecialError cError hi def link cCurlyError cError hi def link cOperator Operator hi def link cStructure Structure +hi def link cTypedef Structure hi def link cStorageClass StorageClass hi def link cInclude Include hi def link cPreProc PreProc diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 820425b..6f5c5a8 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -9,6 +9,9 @@ if exists("b:current_syntax") finish endif +" inform C syntax that the file was included from cpp.vim +let b:filetype_in_cpp_family = 1 + " Read the C syntax to start with runtime! syntax/c.vim unlet b:current_syntax From a36fc80c236d3f4c95d0a44e3bad9be34fe79050 Mon Sep 17 00:00:00 2001 From: "K.Takata" Date: Tue, 19 Jan 2021 11:49:50 +0900 Subject: [PATCH 28/41] Sync upstream --- syntax/cpp.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 6f5c5a8..ed38913 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2017 Jun 05 +" Last Change: 2021 Jan 12 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -58,12 +58,6 @@ if !exists("cpp_no_cpp14") syn case match endif -" C++ 17 extensions -if !exists("cpp_no_cpp17") - syn match cppCast "\]?" From 502a16b6bb892f5d25fc3bc11b15099539c38aaf Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Mon, 12 Apr 2021 22:59:02 +0800 Subject: [PATCH 29/41] Add C++ syntax support for user-defined literals --- syntax/cpp.vim | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index ed38913..de5e7a9 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2021 Jan 12 +" Last Change: 2021 Apr 12 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -44,7 +44,7 @@ if !exists("cpp_no_cpp11") syn keyword cppConstant ATOMIC_WCHAR_T_LOCK_FREE ATOMIC_SHORT_LOCK_FREE syn keyword cppConstant ATOMIC_INT_LOCK_FREE ATOMIC_LONG_LOCK_FREE syn keyword cppConstant ATOMIC_LLONG_LOCK_FREE ATOMIC_POINTER_LOCK_FREE - syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"+ contains=@Spell + syn region cppRawString matchgroup=cppRawStringDelimiter start=+\%(u8\|[uLU]\)\=R"\z([[:alnum:]_{}[\]#<>%:;.?*\+\-/\^&|~!=,"']\{,16}\)(+ end=+)\z1"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ contains=@Spell syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*<"me=e-1 syn match cppCast "\<\(const\|static\|dynamic\)_pointer_cast\s*$" endif @@ -52,14 +52,21 @@ endif " C++ 14 extensions if !exists("cpp_no_cpp14") syn case ignore - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>" contains=cFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>" + syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" contains=cppFloat + syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ end='$' contains=cSpecial,cFormat,@Spell syn case match endif " C++ 20 extensions if !exists("cpp_no_cpp20") + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(y\|d\)\>" + syn match cppNumber display "\<0x\x\('\=\x\+\)*\(y\|d\)\>" syn keyword cppStatement co_await co_return co_yield requires syn keyword cppStorageClass consteval constinit syn keyword cppStructure concept @@ -90,7 +97,9 @@ hi def link cppBoolean Boolean hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String +hi def link cppString String hi def link cppNumber Number +hi def link cppFloat Number hi def link cppModule Include let b:current_syntax = "cpp" From 39764b5fc9ff2ee9c6ceb659deecaa85e95d49c1 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Tue, 13 Apr 2021 22:55:34 +0800 Subject: [PATCH 30/41] Support user-defined literals on octals and 0. --- syntax/cpp.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index de5e7a9..5ad1bc9 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -56,6 +56,8 @@ if !exists("cpp_no_cpp14") syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<0\o\+\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<0\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" contains=cppFloat syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ end='$' contains=cSpecial,cFormat,@Spell @@ -65,6 +67,8 @@ endif " C++ 20 extensions if !exists("cpp_no_cpp20") syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>" + syn match cppNumber display "\<0\o\+\(y\|d\)\>" + syn match cppNumber display "\<0\(y\|d\)\>" syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(y\|d\)\>" syn match cppNumber display "\<0x\x\('\=\x\+\)*\(y\|d\)\>" syn keyword cppStatement co_await co_return co_yield requires From b70920eca22a4b78aa8424e9bac60c0235fa125c Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sat, 17 Apr 2021 00:02:25 +0800 Subject: [PATCH 31/41] Fix: user-defined suffixes are case-sensitive Fix the problem that user-defined literals are highlighted in a way that ignores the case of suffixes. Also, suffixes Ll and lL, which are rejected by compilers, are no longer highlighted as well. --- syntax/cpp.vim | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 5ad1bc9..0c5406a 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -51,17 +51,15 @@ endif " C++ 14 extensions if !exists("cpp_no_cpp14") - syn case ignore - syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([fl]\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<0\o\+\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<0\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" contains=cppFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=ll\=\|ll\=u\|if\|il\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" contains=cppFloat + syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ end='$' contains=cSpecial,cFormat,@Spell - syn case match endif " C++ 20 extensions From 2b204b2f4b8216520d904d67e884b229da70a0cc Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sat, 17 Apr 2021 00:21:08 +0800 Subject: [PATCH 32/41] Better specify user-defined suffixes. Two fixes: 1) allow a single `_`, which is a valid user-defined suffix; 2) use `\i`, which is more concise and arguable better (as many Unicode characters are allowed in identifiers). --- syntax/cpp.vim | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 0c5406a..2de826b 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2021 Apr 12 +" Last Change: 2021 Apr 17 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -51,15 +51,15 @@ endif " C++ 14 extensions if !exists("cpp_no_cpp14") - syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" contains=cppFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=\>" - syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_[_a-zA-Z][_a-zA-Z0-9]*\)\=+ end='$' contains=cSpecial,cFormat,@Spell + syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat + syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell endif " C++ 20 extensions From 802644f2557b43772d3cc4afb94cb3530fae57c3 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sat, 17 Apr 2021 23:16:20 +0800 Subject: [PATCH 33/41] Simplify patterns a bit --- syntax/cpp.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 2de826b..22a91ac 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -51,14 +51,14 @@ endif " C++ 14 extensions if !exists("cpp_no_cpp14") - syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\([FLfl]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[Ff]\|i[Ll]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat + syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell endif From e17fffdbc945ed4a31c59fe62f49949e0fbe8559 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sat, 17 Apr 2021 23:22:18 +0800 Subject: [PATCH 34/41] Fix: forms like 2u were not highlighted as cppNumber They were highlighted as cNumber only. --- syntax/cpp.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 22a91ac..3885caa 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -54,11 +54,11 @@ if !exists("cpp_no_cpp14") syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat + syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell endif From 289c780fbfbf2dfe7049b0cbba9c8b1ef18d5672 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Sat, 17 Apr 2021 23:36:20 +0800 Subject: [PATCH 35/41] Fix: some supported forms were not standard Forms like 2Li or 3.0iF are accepted by GCC, but are not in the standard, and are rejected by some other compilers. Do not highlight them. --- syntax/cpp.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 3885caa..3b12089 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -51,14 +51,14 @@ endif " C++ 14 extensions if !exists("cpp_no_cpp14") - syn match cppFloat display contained "\<\d\+\.\d*\(e[-+]\=\d\+\)\=\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppFloat display contained "\<\.\d\+\(e[-+]\=\d\+\)\=\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppFloat display contained "\<\d\+e[-+]\=\d\+\(i\=[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[FfLl]\|i\|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 cppFloat display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" + syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat + syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell endif From 912a74f4688ab41de7a0bc42523c9585cc6ff52a Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Tue, 4 May 2021 15:00:54 +0800 Subject: [PATCH 36/41] Fix the unintended interaction with c.vim --- syntax/cpp.vim | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 3b12089..32cec34 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -2,7 +2,7 @@ " Language: C++ " Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp) " Previous Maintainer: Ken Shan -" Last Change: 2021 Apr 17 +" Last Change: 2021 May 04 " quit when a syntax file was already loaded if exists("b:current_syntax") @@ -51,24 +51,25 @@ endif " C++ 14 extensions if !exists("cpp_no_cpp14") + syn match cppNumbers display transparent "\<\d\|\.\d" contains=cppNumber,cppFloat + 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*\(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 cppFloat display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\o\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" contains=cppFloat - syn match cppNumber display "\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell endif " C++ 20 extensions if !exists("cpp_no_cpp20") - syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(y\|d\)\>" - syn match cppNumber display "\<0\o\+\(y\|d\)\>" - syn match cppNumber display "\<0\(y\|d\)\>" - syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(y\|d\)\>" - syn match cppNumber display "\<0x\x\('\=\x\+\)*\(y\|d\)\>" + 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 keyword cppStatement co_await co_return co_yield requires syn keyword cppStorageClass consteval constinit syn keyword cppStructure concept From 42ea4533364b7f5e9bf085589f0de3ffb6d83d34 Mon Sep 17 00:00:00 2001 From: Wu Yongwei Date: Tue, 4 May 2021 15:13:38 +0800 Subject: [PATCH 37/41] Add support for C++17 hexadecimal float literals --- syntax/cpp.vim | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 32cec34..3ad79d5 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -63,6 +63,14 @@ if !exists("cpp_no_cpp14") syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell endif +" C++ 17 extensions +if !exists("cpp_no_cpp17") + syn match cppCast "\" + syn match cppFloat display contained "\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" +endif + " C++ 20 extensions if !exists("cpp_no_cpp20") syn match cppNumber display contained "\<0\(y\|d\)\>" @@ -77,12 +85,6 @@ if !exists("cpp_no_cpp20") syn keyword cppModule import module export endif -" C++ 17 extensions -if !exists("cpp_no_cpp17") - syn match cppCast "\]?" From 15b8dd1ee346d6df713ba4da1e84f0432fb5076f Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 16 Aug 2021 02:52:57 +1000 Subject: [PATCH 38/41] Fix error highlighting in valid mulitline raw string literals Fixes #56. --- syntax/cpp.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 3ad79d5..8e2c8e9 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -60,7 +60,7 @@ if !exists("cpp_no_cpp14") 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 cppFloat display contained "\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>" - syn region cppString start=+\(L\|u\|u8\|U\|R\|LR\|u8R\|uR\|UR\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell + syn region cppString start=+\(L\|u\|u8\|U\)\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell endif " C++ 17 extensions From 491499215044ce4b08eb15dca36b0fd70b5cf075 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 23 Aug 2021 22:44:10 +1000 Subject: [PATCH 39/41] Add syntax support for u8 character literals --- syntax/cpp.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 3ad79d5..42709df 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -69,6 +69,20 @@ if !exists("cpp_no_cpp17") syn match cppCast "\" syn match cppFloat display contained "\<0x\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'[^\\]'" + syn match cppCharacter "u8'[^']*'" contains=cSpecial + if exists("c_gnu") + syn match cppSpecialError "u8'\\[^'\"?\\abefnrtv]'" + syn match cppSpecialCharacter "u8'\\['\"?\\abefnrtv]'" + else + syn match cppSpecialError "u8'\\[^'\"?\\abfnrtv]'" + syn match cppSpecialCharacter "u8'\\['\"?\\abfnrtv]'" + endif + syn match cppSpecialCharacter display "u8'\\\o\{1,3}'" + syn match cppSpecialCharacter display "u8'\\x\x\+'" + endif " C++ 20 extensions @@ -99,6 +113,9 @@ hi def link cppType Type hi def link cppStorageClass StorageClass hi def link cppStructure Structure hi def link cppBoolean Boolean +hi def link cppCharacter cCharacter +hi def link cppSpecialCharacter cSpecialCharacter +hi def link cppSpecialError cSpecialError hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String From e955eeb11f328b4bddbfa66527fe9da1af99990b Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Mon, 23 Aug 2021 22:46:24 +1000 Subject: [PATCH 40/41] Whitespace fixes --- syntax/cpp.vim | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/syntax/cpp.vim b/syntax/cpp.vim index 42709df..03f9eb9 100644 --- a/syntax/cpp.vim +++ b/syntax/cpp.vim @@ -103,26 +103,26 @@ endif syn match cppMinMax "[<>]?" " Default highlighting -hi def link cppAccess cppStatement -hi def link cppCast cppStatement +hi def link cppAccess cppStatement +hi def link cppCast cppStatement hi def link cppExceptions Exception -hi def link cppOperator Operator +hi def link cppOperator Operator hi def link cppStatement Statement -hi def link cppModifier Type -hi def link cppType Type -hi def link cppStorageClass StorageClass +hi def link cppModifier Type +hi def link cppType Type +hi def link cppStorageClass StorageClass hi def link cppStructure Structure -hi def link cppBoolean Boolean -hi def link cppCharacter cCharacter -hi def link cppSpecialCharacter cSpecialCharacter -hi def link cppSpecialError cSpecialError -hi def link cppConstant Constant +hi def link cppBoolean Boolean +hi def link cppCharacter cCharacter +hi def link cppSpecialCharacter cSpecialCharacter +hi def link cppSpecialError cSpecialError +hi def link cppConstant Constant hi def link cppRawStringDelimiter Delimiter hi def link cppRawString String -hi def link cppString String -hi def link cppNumber Number -hi def link cppFloat Number -hi def link cppModule Include +hi def link cppString String +hi def link cppNumber Number +hi def link cppFloat Number +hi def link cppModule Include let b:current_syntax = "cpp" From fd95282ade646759dffed24af64c657285094fdf Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 23 Aug 2021 23:37:26 +0900 Subject: [PATCH 41/41] Merge vim/runtime/syntax/c.vim --- syntax/c.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syntax/c.vim b/syntax/c.vim index d07aaf2..20f8632 100644 --- a/syntax/c.vim +++ b/syntax/c.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: C " Maintainer: Bram Moolenaar -" Last Change: 2021 Jan 11 +" Last Change: 2021 May 24 " Quit when a (custom) syntax file was already loaded if exists("b:current_syntax") @@ -414,6 +414,9 @@ if exists("c_autodoc") syn cluster cPreProcGroup add=cAutodocReal endif +" be able to fold #pragma regions +syn region cPragma start="^\s*#pragma\s\+region\>" end="^\s*#pragma\s\+endregion\>" transparent keepend extend fold + " Highlight User Labels syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cBitField,cOctalZero,cCppOutWrapper,cCppInWrapper,@cCppOutInGroup,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString if s:ft ==# 'c' || exists("cpp_no_cpp11")