Skip to content

Commit 414a8ae

Browse files
committed
rebase upstream manually
1 parent e4fadde commit 414a8ae

File tree

2 files changed

+41
-57
lines changed

2 files changed

+41
-57
lines changed

syntax/c.vim

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim syntax file
22
" Language: C
33
" Maintainer: Bram Moolenaar <[email protected]>
4-
" Last Change: 2016 Nov 16
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
370-
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
370+
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*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*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
390-
syn region cPreProc start="\(%:\|#\)\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
@@ -399,18 +399,18 @@ syn cluster cLabelGroup contains=cUserLabel
399399
syn match cUserCont display "^\s*\zs\I\i*\s*:$" contains=@cLabelGroup
400400
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

+18-34
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,14 @@
44
" Previous Maintainer: Ken Shan <[email protected]>
55
" 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
@@ -64,29 +57,20 @@ endif
6457
syn match cppMinMax "[<>]?"
6558

6659
" Default highlighting
67-
if version >= 508 || !exists("did_cpp_syntax_inits")
68-
if version < 508
69-
let did_cpp_syntax_inits = 1
70-
command -nargs=+ HiLink hi link <args>
71-
else
72-
command -nargs=+ HiLink hi def link <args>
73-
endif
74-
HiLink cppAccess cppStatement
75-
HiLink cppCast cppStatement
76-
HiLink cppExceptions Exception
77-
HiLink cppOperator Operator
78-
HiLink cppStatement Statement
79-
HiLink cppModifier Type
80-
HiLink cppType Type
81-
HiLink cppStorageClass StorageClass
82-
HiLink cppStructure Structure
83-
HiLink cppBoolean Boolean
84-
HiLink cppConstant Constant
85-
HiLink cppRawStringDelimiter Delimiter
86-
HiLink cppRawString String
87-
HiLink cppNumber Number
88-
delcommand HiLink
89-
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
9074

9175
let b:current_syntax = "cpp"
9276

0 commit comments

Comments
 (0)