b4winckler / vim-objc

My Objective-C config for Vim
77 stars 6 forks source link

Block formatting #5

Closed keith closed 9 years ago

keith commented 10 years ago

There is an issue with indenting blocks after the first newline. The first time you press enter after creating the block you get your single shiftwidth indent declared here. On the second time since the previous line does not match the block pattern the indent falls through to the normal cindent which breaks it.

I think the only way to get around this would be to attempt to figure out if you were still in a block on the newline. Even if it was multiple lines up. I believe this is also the issue mentioned in https://github.com/b4winckler/vim-objc/issues/2

Another possible option would just be to check the current line for the closing block pattern. If so just do the single indent. Partially related I think there should be an option for whether you want to indent the closing block characters or not.

    describe(@"", ^{
        })  <- First Indent
            }) <- Second newline

Opinions on this?

keith commented 10 years ago

This can be fixed by changing this check to thisLine =~ '})' to check if the line you're pushing around is the end of a block. I also prefer the inside of the block to just be return ind but like I said that could possible be exposed as an option.