Create a gist now

Instantly share code, notes, and snippets.

diff -ur /home/mattn/dev/vim/runtime/syntax/c.vim syntax/c.vim
--- /home/mattn/dev/vim/runtime/syntax/c.vim 2013-03-09 22:50:46.434180219 +0900
+++ syntax/c.vim 2013-03-09 23:20:48.550208870 +0900
@@ -110,30 +110,57 @@
" 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")
- syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@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 "^[{}]\|^<%\|^%>"
+ if &filetype ==# 'cpp' && !exists("cpp_no_cpp11")
+ syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@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
+ " 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 "^[{}]\|^<%\|^%>"
+ end
elseif exists("c_no_bracket_error")
- syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cCppString,@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 "[{}]\|<%\|%>"
+ if &filetype ==# 'cpp' && !exists("cpp_no_cpp11")
+ syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@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
+ " 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 "[{}]\|<%\|%>"
+ end
else
- syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@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
+ if &filetype ==# 'cpp' && !exists("cpp_no_cpp11")
+ syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@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
+ else
+ syn region cParen transparent start='(' end=')' end='}'me=s-1 contains=ALLBUT,cBlock,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@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
+ 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
syn match cErrInBracket display contained "[);{}]\|<%\|%>"
endif
-syntax region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold
+if &filetype ==# 'c' || exists("cpp_no_cpp11")
+ syn region cBadBlock keepend start="{" end="}" contained containedin=cParen,cBracket,cBadBlock transparent fold
+endif
"integer number, or floating point number without a dot and with "f".
syn case ignore
@@ -170,16 +197,16 @@
" need to use a special type of cString: cCommentString, which also ends on
" "*/", and sees a "*" at the start of the line as comment again.
" Unfortunately this doesn't very well work for // type of comments :-(
- syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)"
- syntax region cCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
- syntax region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
- syntax region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell
+ syn match cCommentSkip contained "^\s*\*\($\|\s\+\)"
+ syn region cCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=cSpecial,cCommentSkip
+ syn region cComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=cSpecial
+ syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cComment2String,cCharacter,cNumbersCom,cSpaceError,@Spell
if exists("c_no_comment_fold")
" Use "extend" here to have preprocessor lines not terminate halfway a
" comment.
- syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend
+ syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell extend
else
- syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold extend
+ syn region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold extend
endif
else
syn region cCommentL start="//" skip="\\$" end="$" keepend contains=@cCommentGroup,cSpaceError,@Spell
@@ -190,8 +217,8 @@
endif
endif
" keep a // comment separately, it terminates a preproc. conditional
-syntax match cCommentError display "\*/"
-syntax match cCommentStartError display "/\*"me=e-1 contained
+syn match cCommentError display "\*/"
+syn match cCommentStartError display "/\*"me=e-1 contained
syn keyword cOperator sizeof
if exists("c_gnu")
@@ -343,7 +370,9 @@
" 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
-syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell
+if &filetype ==# 'c' || exists("cpp_no_cpp11")
+ syn region cMulti transparent start='?' skip='::' end=':' contains=ALLBUT,@cMultiGroup,@Spell
+end
" 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
diff -ur /home/mattn/dev/vim/runtime/syntax/cpp.vim syntax/cpp.vim
--- /home/mattn/dev/vim/runtime/syntax/cpp.vim 2010-09-07 22:39:02.665446683 +0900
+++ syntax/cpp.vim 2013-03-09 22:55:22.070184599 +0900
@@ -1,7 +1,8 @@
" Vim syntax file
" Language: C++
-" Maintainer: Ken Shan <ccshan@post.harvard.edu>
-" Last Change: 2002 Jul 15
+" Current Maintainer: vim-jp (https://github.com/vim-jp/cpp-vim)
+" Previous Maintainer: Ken Shan <ccshan@post.harvard.edu>
+" Last Change: 2012 Jun 14
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
@@ -19,7 +20,7 @@
unlet b:current_syntax
endif
-" C++ extentions
+" 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
@@ -30,9 +31,16 @@
syn match cppCast "\<\(const\|static\|dynamic\|reinterpret\)_cast\s*$"
syn keyword cppStorageClass mutable
syn keyword cppStructure class typename template namespace
-syn keyword cppNumber NPOS
syn keyword cppBoolean true false
+" C++ 11 extensions
+if !exists("cpp_no_cpp11")
+ syn keyword cppType override final
+ syn keyword cppExceptions noexcept
+ syn keyword cppStorageClass constexpr decltype
+ syn keyword cppConstant nullptr
+endif
+
" The minimum and maximum operators in GNU C++
syn match cppMinMax "[<>]?"
@@ -52,8 +60,8 @@
HiLink cppType Type
HiLink cppStorageClass StorageClass
HiLink cppStructure Structure
- HiLink cppNumber Number
HiLink cppBoolean Boolean
+ HiLink cppConstant Constant
delcommand HiLink
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment