summaryrefslogtreecommitdiffstats
path: root/runtime/syntax/c.vim
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/syntax/c.vim')
-rw-r--r--runtime/syntax/c.vim17
1 files changed, 10 insertions, 7 deletions
diff --git a/runtime/syntax/c.vim b/runtime/syntax/c.vim
index a39fbd80e2..7164e14ed8 100644
--- a/runtime/syntax/c.vim
+++ b/runtime/syntax/c.vim
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: C
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2006 May 01
+" Last Change: 2007 Feb 13
" Quit when a (custom) syntax file was already loaded
if exists("b:current_syntax")
@@ -64,6 +64,9 @@ if exists("c_space_errors")
endif
endif
+" This should be before cErrInParen to avoid problems with #define ({ xxx })
+syntax region cBlock start="{" end="}" transparent fold
+
"catch errors caused by wrong parenthesis and brackets
" also accept <% for {, %> for }, <: for [ and :> for ] (C99)
" But avoid matching <::.
@@ -132,9 +135,11 @@ if exists("c_comment_strings")
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
if exists("c_no_comment_fold")
- syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell
+ " 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
else
- syntax region cComment matchgroup=cCommentStart start="/\*" end="\*/" contains=@cCommentGroup,cCommentStartError,cCommentString,cCharacter,cNumbersCom,cSpaceError,@Spell fold
+ syntax 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
@@ -148,8 +153,6 @@ endif
syntax match cCommentError display "\*/"
syntax match cCommentStartError display "/\*"me=e-1 contained
-syntax region cBlock start="{" end="}" transparent fold
-
syn keyword cOperator sizeof
if exists("c_gnu")
syn keyword cStatement __asm__
@@ -158,7 +161,7 @@ endif
syn keyword cType int long short char void
syn keyword cType signed unsigned float double
if !exists("c_no_ansi") || exists("c_ansi_typedefs")
- syn keyword cType size_t ssize_t wchar_t ptrdiff_t sig_atomic_t fpos_t
+ syn keyword cType size_t ssize_t off_t wchar_t ptrdiff_t sig_atomic_t fpos_t
syn keyword cType clock_t time_t va_list jmp_buf FILE DIR div_t ldiv_t
syn keyword cType mbstate_t wctrans_t wint_t wctype_t
endif
@@ -273,7 +276,7 @@ syn match cIncluded display contained "<[^>]*>"
syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded
"syn match cLineSkip "\\$"
syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti
-syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 contains=ALLBUT,@cPreProcGroup,@Spell
+syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 keepend contains=ALLBUT,@cPreProcGroup,@Spell
syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell
" Highlight User Labels