8000 Sync upstream · reaalkhalil/vim-cpp@b501ec0 · GitHub
[go: up one dir, main page]

Skip to content

Commit b501ec0

Browse files
committed
Sync upstream
1 parent 7dab118 commit b501ec0

File tree

2 files changed

+49
-61
lines changed

2 files changed

+49
-61
lines changed

syntax/c.vim

Lines changed: 24 additions & 24 deletions
F438
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim syntax file
22
" Language: C
33
" Maintainer: Bram Moolenaar <Bram@vim.org>
4-
" Last Change: 2016 Jul 07
4+
" Last Change: 2016 Nov 17
55

66
" Quit when a (custom) syntax file was already loaded
77
if exists("b:current_syntax")
@@ -358,36 +358,36 @@ if !exists("c_no_c99") " ISO C99
358358
endif
359359

360360
" Accept %: for # (C99)
361-
syn region cPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
362-
syn match cPreConditMatch display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
361+
syn region cPreCondit start="^\s*\zs\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError
362+
syn match cPreConditMatch display "^\s*\zs\(%:\|#\)\s*\(else\|endif\)\>"
363363
if !exists("c_no_if0")
364364
syn cluster cCppOutInGroup contains=cCppInIf,cCppInElse,cCppInElse2,cCppOutIf,cCppOutIf2,cCppOutElse,cCppInSkip,cCppOutSkip
365-
syn region cCppOutWrapper start="^\s*\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
366-
syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
365+
syn region cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
366+
syn region cCppOutIf contained start="0\+" matchgroup=cCppOutWrapper end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cCppOutIf2,cCppOutElse
367367
if !exists("c_no_if0_fold")
368368
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
369369
else
370370
syn region cCppOutIf2 contained matchgroup=cCppOutWrapper start="0\+" end="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0\+\s*\($\|//\|/\*\|&\)\)\@!\|endif\>\)"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
371371
endif
372-
syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
373-
syn region cCppInWrapper start="^\s*\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
374-
syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
372+
syn region cCppOutElse contained matchgroup=cCppOutWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=TOP,cPreCondit
373+
syn region cCppInWrapper start="^\s*\zs\(%:\|#\)\s*if\s\+0*[1-9]\d*\s*\($\|//\|/\*\||\)" end=".\@=\|$" contains=cCppInIf,cCppInElse fold
374+
syn region cCppInIf contained matchgroup=cCppInWrapper start="\d\+" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=TOP,cPreCondit
375375
if !exists("c_no_if0_fold")
376-
syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
376+
syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2 fold
377377
else
378-
syn region cCppInElse contained start="^\s*\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
378+
syn region cCppInElse contained start="^\s*\zs\(%:\|#\)\s*\(else\>\|elif\s\+\(0*[1-9]\d*\s*\($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=cCppInIf contains=cCppInElse2
379379
endif
380-
syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
381-
syn region cCppOutSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
382-
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
380+
syn region cCppInElse2 contained matchgroup=cCppInWrapper start="^\s*\zs\(%:\|#\)\s*\(else\|elif\)\([^/]\|/[^/*]\)*" end="^\s*\zs\(%:\|#\)\s*endif\>"me=s-1 contains=cSpaceError,cCppOutSkip,@Spell
381+
syn region cCppOutSkip contained start="^\s*\zs\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\zs\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppOutSkip
382+
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
383383
endif
384384
syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
385385
syn match cIncluded display contained "<[^>]*>"
386-
syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
386+
syn match cInclude display "^\s*\zs\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
387387
"syn match cLineSkip "\\$"
388388
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
389-
syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
390-
syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
389+
syn region cDefine start="^\s*\zs\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
390+
syn region cPreProc start="^\s*\zs\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
391391

392392
" Highlight User Labels
393393
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
@@ -396,21 +396,21 @@ if s:ft ==# 'c' || exists("cpp_no_cpp11")
396396
endif
397397
" Avoid matching foo::bar() in C++ by requiring that the next char is not ':'
398398
syn cluster cLabelGroup contains=cUserLabel
399-
syn match cUserCont display "^\s*\I\i*\s*:$" contains=@cLabelGroup
400-
syn match cUserCont display ";\s*\I\i*\s*:$" contains=@cLabelGroup
399+
syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup
400+
syn match cUserCont display ";\s*\zs\I\i*\s*:$" contains=@cLabelGroup
401401
if s:ft ==# 'cpp'
402-
syn match cUserCont display "^\s*\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
403-
syn match cUserCont display ";\s*\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
402+
syn match cUserCont display "^\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
403+
syn match cUserCont display ";\s*\zs\%(class\|struct\|enum\)\@!\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
404404
else
405-
syn match cUserCont display "^\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
406-
syn match cUserCont display ";\s*\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
405+
syn match cUserCont display "^\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
406+
syn match cUserCont display ";\s*\zs\I\i*\s*:[^:]"me=e-1 contains=@cLabelGroup
407407
endif
408408

409409
syn match cUserLabel display "\I\i*" contained
410410

411411
" Avoid recognizing most bitfields as labels
412-
syn match cBitField display "^\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType
413-
syn match cBitField display ";\s*\I\i*\s*:\s*[1-9]"me=e-1 contains=cType
412+
syn match cBitField display "^\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType
413+
syn match cBitField display ";\s*\zs\I\i*\s*:\s*[1-9]"me=e-1 contains=cType
414414

415415
if exists("c_minlines")
416416
let b:c_minlines = c_minlines

syntax/cpp.vim

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,16 @@
22
" Language: C++
33
" Current Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
44
" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
5-
" Last Change: 2016 Jul 07
5+
" Last Change: 2016 Oct 28
66

7-
" For version 5.x: Clear all syntax items
8-
" For version 6.x: Quit when a syntax file was already loaded
9-
if version < 600
10-
syntax clear
11-
elseif exists("b:current_syntax")
7+
" quit when a syntax file was already loaded
8+
if exists("b:current_syntax")
129
finish
1310
endif
1411

1512
" Read the C syntax to start with
16-
if version < 600
17-
so <sfile>:p:h/c.vim
18-
else
19-
runtime! syntax/c.vim
20-
unlet b:current_syntax
21-
endif
13+
runtime! syntax/c.vim
14+
unlet b:current_syntax
2215

2316
" C++ extensions
2417
syn keyword cppStatement new delete this friend using
@@ -38,7 +31,7 @@ syn keyword cppConstant __cplusplus
3831
" C++ 11 extensions
3932
if !exists("cpp_no_cpp11")
4033
syn keyword cppModifier override final
41-
syn keyword cppType nullptr_t
34+
syn keyword cppType nullptr_t auto
4235
syn keyword cppExceptions noexcept
4336
syn keyword cppStorageClass constexpr decltype thread_local
4437
syn keyword cppConstant nullptr
@@ -53,36 +46,31 @@ endif
5346

5447
" C++ 14 extensions
5548
if !exists("cpp_no_cpp14")
56-
syn match cppNumber display "\<0b[01]\+\(u\=l\{0,2}\|ll\=u\)\>"
49+
syn case ignore
50+
syn match cppNumber display "\<0b[01]\('\=[01]\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
51+
syn match cppNumber display "\<[1-9]\('\=\d\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
52+
syn match cppNumber display "\<0x\x\('\=\x\+\)*\(u\=l\{0,2}\|ll\=u\)\>"
53+
syn case match
5754
endif
5855

5956
" The minimum and maximum operators in GNU C++
6057
syn match cppMinMax "[<>]?"
6158

6259
" Default highlighting
63-
if version >= 508 || !exists("did_cpp_syntax_inits")
64-
if version < 508
65-
let did_cpp_syntax_inits = 1
66-
command -nargs=+ HiLink hi link <args>
67-
else
68-
command -nargs=+ HiLink hi def link <args>
69-
endif
70-
HiLink cppAccess cppStatement
71-
HiLink cppCast cppStatement
72-
HiLink cppExceptions Exception
73-
HiLink cppOperator Operator
74-
HiLink cppStatement Statement
75-
HiLink cppModifier Type
76-
HiLink cppType Type
77-
HiLink cppStorageClass StorageClass
78-
HiLink cppStructure Structure
79-
HiLink cppBoolean Boolean
80-
HiLink cppConstant Constant
81-
HiLink cppRawStringDelimiter Delimiter
82-
HiLink cppRawString String
83-
HiLink cppNumber Number
84-
delcommand HiLink
85-
endif
60+
hi def link cppAccess cppStatement
61+
hi def link cppCast cppStatement
62+
hi def link cppExceptions Exception
63+
hi def link cppOperator Operator
64+
hi def link cppStatement Statement
65+
hi def link cppModifier Type
66+
hi def link cppType Type
67+
hi def link cppStorageClass StorageClass
68+
hi def link cppStructure Structure
69+
hi def link cppBoolean Boolean
70+
hi def link cppConstant Constant
71+
hi def link cppRawStringDelimiter Delimiter
72+
hi def link cppRawString String
73+
hi def link cppNumber Number
8674

8775
let b:current_syntax = "cpp"
8876

0 commit comments

Comments
 (0)
0