8000 Add option g:pymode_indent_hanging_width · python-mode/python-mode@7487b79 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7487b79

Browse files
committed
Add option g:pymode_indent_hanging_width
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.
1 parent 56a4b36 commit 7487b79

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

autoload/pymode/indent.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ function! pymode#indent#get_indent(lnum)
2424
if closing_paren
2525
return indent(parlnum)
2626
else
27-
return indent(parlnum) + &shiftwidth
27+
let l:indent_width = (g:pymode_indent_hanging_width > 0 ?
28+
\ g:pymode_indent_hanging_width : &shiftwidth)
29+
return indent(parlnum) + l:indent_width
2830
endif
2931
else
3032
return parcol

doc/pymode.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ Enable pymode indentation *'g:pymode_indent'
170170
>
171171
let g:pymode_indent = 1
172172
173+
174+
Customization:
175+
176+
Hanging indent size after an open parenthesis or bracket (but nothing after the
177+
parenthesis), when vertical alignment is not used. Defaults to `&shiftwidth`.
178+
*'g:pymode_indent_hanging_width'*
179+
>
180+
let g:pymode_indent_hanging_width = &shiftwidth
181+
let g:pymode_indent_hanging_width = 4
182+
173183
-------------------------------------------------------------------------------
174184
2.3 Python folding ~
175185
*pymode-folding*

plugin/pymode.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ call pymode#default('g:pymode_doc_bind', 'K')
3838
" Enable/Disable pymode PEP8 indentation
3939
call pymode#default("g:pymode_indent", 1)
4040

41+
" Customize hanging indent size different than &shiftwidth
42+
call pymode#default("g:pymode_indent_hanging_width", -1)
43+
4144
" TODO: currently folding suffers from a bad performance and incorrect
4245
" implementation. This feature should be considered experimental.
4346
" Enable/disable pymode folding for pyfiles.

0 commit comments

Comments
 (0)
0