X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/483714e35a84d44bfe65f697f12f40367e3676ed..6e60ef05e7335ae4e5dd6a6a973c62f2a29198e4:/indent/python.vim diff --git a/indent/python.vim b/indent/python.vim index 82f0d7c..9c3aa0c 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -15,7 +15,7 @@ let b:did_indent = 1 setlocal expandtab setlocal nolisp setlocal autoindent -setlocal indentexpr=GetPythonIndent(v:lnum) +setlocal indentexpr=GetPythonPEPIndent(v:lnum) setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except let s:maxoff = 50 @@ -101,7 +101,7 @@ function! s:BlockStarter(lnum, block_start_re) return -1 endfunction -function! GetPythonIndent(lnum) +function! GetPythonPEPIndent(lnum) " First line has indent 0 if a:lnum == 1 @@ -172,9 +172,9 @@ function! GetPythonIndent(lnum) endif endif - " If the previous line ended with a colon, indent relative to - " statement start. - if pline =~ ':\s*$' + " If the previous line ended with a colon and is not a comment, indent + " relative to statement start. + if pline =~ '^[^#]*:\s*\(#.*\)\?$' return indent(sslnum) + &sw endif