From: Daniel Hahler Date: Sun, 22 Jul 2018 21:54:26 +0000 (+0200) Subject: Address Flake8's E127 with "if (" (#102) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/fef375966a19e70af820e18b50d82b55157b3a41 Address Flake8's E127 with "if (" (#102) > continuation line over-indented for visual indent It appears that the "if (" is just the 4 columns wide that triggers the extra indent with sw=4. Might also change/adjust b:control_statement to ignore `if (`, but this appears to be more flexible/correct. --- diff --git a/indent/python.vim b/indent/python.vim index a095ca6..b863370 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -225,10 +225,13 @@ function! s:indent_like_opening_paren(lnum) " indent further to distinguish the continuation line " from the next logical line. if text =~# b:control_statement && res == base + s:sw() - return base + s:sw() * 2 - else - return res + " But only if not inside parens itself (Flake's E127). + let [paren_lnum, _] = s:find_opening_paren(paren_lnum) + if paren_lnum <= 0 + return res + s:sw() + endif endif + return res endfunction " Match indent of first block of this type. diff --git a/spec/indent/indent_spec.rb b/spec/indent/indent_spec.rb index d369c3e..a85edcc 100644 --- a/spec/indent/indent_spec.rb +++ b/spec/indent/indent_spec.rb @@ -251,6 +251,11 @@ shared_examples_for "vim" do indent.should == 0 end + it "handles nested expressions (Flake8's E127)" do + vim.feedkeys 'i[\x for x in foo\if (\' + indent.should == shiftwidth * 2 + end + it "still handles multiple parens correctly" do vim.feedkeys 'iif (111 and (222 and 333\' indent.should == 13