Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add g:python_pep8_indent_continuation_indent_width #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ With content already, it will be aligned to the opening parenthesis::

Existing indentation (including ``0``) in multiline strings will be kept, so this setting only applies to the indentation of new/empty lines.

python_pep8_indent_continuation_indent_width
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This option specifies the indent width used for line continuations from a parenthesis/bracket/brace.

.. code-block:: vim
let g:python_pep8_indent_continuation_indent_width = 4 " default
let g:python_pep8_indent_continuation_indent_width = "&sw * 2"
let g:python_pep8_indent_continuation_indent_width = 8

Notes
-----
Expand Down
6 changes: 5 additions & 1 deletion indent/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ if !exists('g:python_pep8_indent_multiline_string')
let g:python_pep8_indent_multiline_string = 0
endif

if !exists('g:python_pep8_indent_continuation_indent_width')
let g:python_pep8_indent_continuation_indent_width = 4
endif

let s:maxoff = 50
let s:block_rules = {
\ '^\s*elif\>': ['if', 'elif'],
Expand Down Expand Up @@ -212,7 +216,7 @@ function! s:indent_like_opening_paren(lnum)
if starts_with_closing_paren
let res = base
else
let res = base + s:sw()
let res = base + eval(g:python_pep8_indent_continuation_indent_width)
endif
else
" Indent to match position of opening paren.
Expand Down
18 changes: 9 additions & 9 deletions spec/indent/indent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
before { vim.feedkeys 'itest(\<CR>' }

it "indents by one level" do
proposed_indent.should == shiftwidth
proposed_indent.should satisfy { |v| v == shiftwidth * 2 or v == 4 }
vim.feedkeys 'something'
indent.should == shiftwidth
indent.should == 4
vim.normal '=='
indent.should == shiftwidth
indent.should == 4
end

it "puts the closing parenthesis at the same level" do
Expand Down Expand Up @@ -80,9 +80,9 @@
before { vim.feedkeys 'imydict = { # comment\<CR>' }

it "indent by one level" do
indent.should == shiftwidth
indent.should == 4
vim.feedkeys '1: 1,\<CR>'
indent.should == shiftwidth
indent.should == 4
end

it "lines up the closing parenthesis" do
Expand All @@ -102,7 +102,7 @@
describe "when after multiple parens of different types" do
it "indents by one level" do
vim.feedkeys 'if({\<CR>'
indent.should == shiftwidth
indent.should == 4
end

it "lines up with the last paren" do
Expand Down Expand Up @@ -171,14 +171,14 @@
describe "when using a function definition" do
it "indents shiftwidth spaces" do
vim.feedkeys 'idef long_function_name(\<CR>arg'
indent.should == shiftwidth * 2
indent.should satisfy { |v| v == shiftwidth * 2 or v == 4 }
end
end

describe "when using a class definition" do
it "indents shiftwidth spaces" do
vim.feedkeys 'iclass Foo(\<CR>'
indent.should == shiftwidth * 2
indent.should satisfy { |v| v == shiftwidth * 2 or v == 4 }
end
end

Expand Down Expand Up @@ -379,7 +379,7 @@

it "ignores the call signature after a function" do
vim.feedkeys 'idef f( JEDI_CALL_SIGNATURE\<CR>'
indent.should == shiftwidth * 2
indent.should satisfy { |v| v == shiftwidth * 2 or v == 4 }
end
end
end
Expand Down