swekaj / php-foldexpr.vim

Vim folding for PHP with foldexpr
MIT License
41 stars 10 forks source link

Fold method chaining #9

Closed swekaj closed 10 years ago

swekaj commented 10 years ago

Add an option for folding method chains. The foldtext should display the chain as if it's on one line.

function let(Config $config)
{
    $config
        ->get('.buildable')
        ->willReturn('value');
}

Should fold into

function let(Config $config)
{
 +--- 3 lines: $config->get(...)->willReturn(...)-----------------------------
}
swekaj commented 10 years ago

Did some investigation on this. While the example given would be quite easy to fold, something like

function let(Config $config)
{
    $config
        ->get('.buildbale')
        ->willReturn([
            'value1',
            'value2'
        ]);
}

is a lot harder to handle. It's very difficult to figure out that the ]); line not only closes the fold created by the opening '([' line, but also the fold created by the $config line.