jwalton512 / vim-blade

Vim syntax highlighting for Blade templates.
225 stars 37 forks source link

Fix PHP indentation #50

Closed adriaanzon closed 8 years ago

adriaanzon commented 8 years ago

I actually based this on the branch of @zcodes because he already had some code that I could use as an example. So when you're merging this, you might want to merge his changes first.

Also, when you're going to merge these pull requests, you will probably run into some conflicts. To get a hint on how these should be merged, you could take a look at my master branch. I already have them merged there.

So, this pull request adds indentation for all multiline PHP statements. By that I mean everything in between <?php ?>, {{ }}, {!! !!} and also between the parentheses of @include() (for when you pass a large array to an included view).

The only place where it doesn't work properly yet, is when you have a function call inside @include(). It will falsely recognize the closing parenthesis of the function call as the closing parenthesis of the include statement. If someone knows how to solve this, that would be nice. But I already think it is a lot better than no indentation at all, and most of the time you won't have a function call inside an include statement anyway.

adriaanzon commented 8 years ago

I just added a commit (6eba802) that made me think the cindent variable should actually be indent(lnum-1). Is that true? I'm not really sure what the 'rules' are when writing indent scripts.

adriaanzon commented 8 years ago

Just amended a fix to my last commit, I introduced another bug.