Skip to content

Commit

Permalink
Add option g:pymode_indent_hanging_width
Browse files Browse the repository at this point in the history
This is an option for hanging indent size after an open parenthesis
in line continuations. It defaults to `&shiftwidth` but can be assigned
a different value.

For example, hanging indent size can be set to 4 (even if the tabsize
or shiftwidth is not 4) as per Google Python Style Guide.
  • Loading branch information
wookayin committed Aug 12, 2021
1 parent 56a4b36 commit 7487b79
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion autoload/pymode/indent.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function! pymode#indent#get_indent(lnum)
if closing_paren
return indent(parlnum)
else
return indent(parlnum) + &shiftwidth
let l:indent_width = (g:pymode_indent_hanging_width > 0 ?
\ g:pymode_indent_hanging_width : &shiftwidth)
return indent(parlnum) + l:indent_width
endif
else
return parcol
Expand Down
10 changes: 10 additions & 0 deletions doc/pymode.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ Enable pymode indentation *'g:pymode_indent'
>
let g:pymode_indent = 1
Customization:

Hanging indent size after an open parenthesis or bracket (but nothing after the
parenthesis), when vertical alignment is not used. Defaults to `&shiftwidth`.
*'g:pymode_indent_hanging_width'*
>
let g:pymode_indent_hanging_width = &shiftwidth
let g:pymode_indent_hanging_width = 4
-------------------------------------------------------------------------------
2.3 Python folding ~
*pymode-folding*
Expand Down
3 changes: 3 additions & 0 deletions plugin/pymode.vim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ call pymode#default('g:pymode_doc_bind', 'K')
" Enable/Disable pymode PEP8 indentation
call pymode#default("g:pymode_indent", 1)

" Customize hanging indent size different than &shiftwidth
call pymode#default("g:pymode_indent_hanging_width", -1)

" TODO: currently folding suffers from a bad performance and incorrect
" implementation. This feature should be considered experimental.
" Enable/disable pymode folding for pyfiles.
Expand Down

0 comments on commit 7487b79

Please sign in to comment.