StanAngeloff / php.vim

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

Breaks indentations on try with multiple catch blocks #93

Open pangteypiyush opened 5 years ago

pangteypiyush commented 5 years ago

php.vim plugin enabled:

<?php

namespace Abc;

class Xyz
{
    public function __construct()
    {
        try {
            // cause exception
        } catch (\AbcException $e) {
            // handle AbcException
        } catch (\PqrException $e) {
            // handle PqrException
        }
        }
        }

        function func() {
            try {
                // cause exception
            } catch (\AbcException $e) {
                // handle AbcException
            } catch (\PqrException $e) {
                // handle PqrException
            }
            }

php.vim plugin disabled:

<?php

namespace Abc;

class Xyz
{
    public function __construct()
    {
        try {
            // cause exception
        } catch (\AbcException $e) {
            // handle AbcException
        } catch (\PqrException $e) {
            // handle PqrException
        }
    }
}

function func() {
    try {
        // cause exception
    } catch (\AbcException $e) {
        // handle AbcException
    } catch (\PqrException $e) {
        // handle PqrException
    }
}

NVIM v0.3.7

vimrc (link):

set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'tobyS/vmustache'
Plugin 'tobyS/pdv'
Plugin 'StanAngeloff/php.vim'
Plugin 'lvht/phpcd.vim'
call vundle#end()
StanAngeloff commented 5 years ago

This seems to be caused by setting php_folding = 1. That feature creates new syntax groups which the built-in indentation doesn't support.

I don't think there's a workaround other than using php_folding = 0 or omitting setting the variable altogether.

pangteypiyush commented 5 years ago

This works fine for me since I don't use php_folding heavily.