StanAngeloff / php.vim

An up-to-date Vim syntax for PHP (7.x supported)
477 stars 69 forks source link

PHP closing tag in DocBlock #51

Closed janhenkgerritsen closed 8 years ago

janhenkgerritsen commented 8 years ago

If you have a PHP closing tag in a DocBlock comment syntax highlighting will go wrong after that closing tag.

An example of such a DocBlock:

    /** 
     * Disable middleware for the next requests.
     *
     * ``` php
     * <?php
     * $I->disableMiddleware();
     * ?>
     * ``` 
     */  

These types of DocBlocks are used by Codeception to document the behavior of modules.

StanAngeloff commented 8 years ago

Ah this is nasty. The Vim syntax region ends regardless of being inside a comment block. This doesn't happen in a string so there's a way around it. Leaving open to investigate.

StanAngeloff commented 8 years ago

Do you mind editing your syntax/php.vim by hand and adding the keyword extend preceded by a space on the line containing SynFoldDoc syn region phpDocComment?

That should be around line 598 +/- a couple of lines. The full line will then read:

  SynFoldDoc syn region phpDocComment   start="/\*\*" end="\*/" keepend contains=phpCommentTitle,phpDocTags,phpTodo,@Spell extend
  "
  "                                                                                                              Add this ^^^^^^^

Do you see any weird issues in your PHP files after this change?

janhenkgerritsen commented 8 years ago

That fixes my problem and it does not seem to affect anything else.

Thanks for looking into it!

StanAngeloff commented 8 years ago

I'll let this one sit for a few days to give you and me the chance to run with the modified code before releasing in the repository for everyone else.

You may encounter a conflict once merged, hopefully if you haven't made any more changes it's a straightforward replace with the upstream version.