X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/5f4184fb1200b329e810c1e4c866c86fdf44c135..fef375966a19e70af820e18b50d82b55157b3a41:/indent/python.vim?ds=sidebyside diff --git a/indent/python.vim b/indent/python.vim index 86155cf..b863370 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -34,6 +34,10 @@ if !exists('g:python_pep8_indent_multiline_string') let g:python_pep8_indent_multiline_string = 0 endif +if !exists('g:python_pep8_indent_hang_closing') + let g:python_pep8_indent_hang_closing = 0 +endif + let s:block_rules = { \ '^\s*elif\>': ['if', 'elif'], \ '^\s*except\>': ['try', 'except'], @@ -203,8 +207,11 @@ function! s:indent_like_opening_paren(lnum) \ s:skip_after_opening_paren, paren_lnum, paren_col+1) let starts_with_closing_paren = getline(a:lnum) =~# '^\s*[])}]' + let hang_closing = get(b:, 'python_pep8_indent_hang_closing', + \ get(g:, 'python_pep8_indent_hang_closing', 0)) + if nothing_after_opening_paren - if starts_with_closing_paren + if starts_with_closing_paren && !hang_closing let res = base else let res = base + s:sw() @@ -218,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.