Skip to content
This repository was archived by the owner on Jan 6, 2026. It is now read-only.
This repository was archived by the owner on Jan 6, 2026. It is now read-only.

Wrong C++ highlighting #41

Open
Open

Description

@mattn

Activity

  1. mattn commented on Aug 29, 2016

    @mattn
    MemberAuthor

    I'm not sure, but removing ^ fixes this syntax.

    diff --git a/syntax/c.vim b/syntax/c.vim
    index 85042e4..b7dedb3 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*\(%:\|#\)\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*\(%:\|#\)\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
    
     " 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
  2. rhysd commented on Sep 1, 2016

    @rhysd
    Contributor

    I think \s* at the head of pattern should be removed as well.

  3. mattn commented on Sep 1, 2016

    @mattn
    MemberAuthor

    right

  4. brammool commented on Nov 17, 2016

    @brammool

    Since when is putting a comment before #if valid C?

  5. mattn commented on Nov 18, 2016

    @mattn
    MemberAuthor

    @brammool This should fix it.

    8976dec

    diff --git a/syntax/c.vim b/syntax/c.vim
    index cc99f67..82148e7 100644
    --- a/syntax/c.vim
    +++ b/syntax/c.vim
    @@ -358,8 +358,8 @@ if !exists("c_no_c99") " ISO C99
     endif
    
     " Accept %: for # (C99)
    -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\)\>"
    +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*\zs\(%:\|#\)\s*if\s\+0\+\s*\($\|//\|/\*\|&\)" end=".\@=\|$" contains=cCppOutIf,cCppOutElse,@NoSpell fold
  6. mattn commented on Nov 18, 2016

    @mattn
    MemberAuthor

    @brammool or, do you ask me why need this change?

  7. mattn commented on Nov 18, 2016

    @mattn
    MemberAuthor

    @brammool Ah, I understanded it just now. vim/vim#1257 (comment)

  8. mattn commented on Apr 26, 2017

    @mattn
    MemberAuthor

    I rebased this repository. And reverted 8976dec

    So this issue still are remaining.

  9. reopened this on Apr 26, 2017
  10. brammool commented on May 15, 2017

    @brammool
  11. brammool commented on May 16, 2017

    @brammool
  12. mattn commented on May 17, 2017

    @mattn
    MemberAuthor

    To fix this, it need the regexp pattern enough to be confusable. And it will take heavy load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions