From: Daniel Hahler Date: Wed, 6 May 2015 16:07:18 +0000 (+0200) Subject: Add more indentation after function/class definition X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/a946371787067299e53338857b792005b84d8962?ds=sidebyside;hp=-c Add more indentation after function/class definition Fixes https://github.com/hynek/vim-python-pep8-indent/issues/30 --- a946371787067299e53338857b792005b84d8962 diff --git a/indent/python.vim b/indent/python.vim index 6912899..007c7e1 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -40,7 +40,7 @@ let s:block_rules = { \ '^\s*finally\>': ['try', 'except', 'else'] \ } let s:paren_pairs = ['()', '{}', '[]'] -let s:control_statement = '^\s*\(if\|while\|with\|for\|except\)\>' +let s:control_statement = '^\s*\(class\|def\|if\|while\|with\|for\|except\)\>' let s:stop_statement = '^\s*\(break\|continue\|raise\|return\|pass\)\>' " Skip strings and comments diff --git a/spec/indent/indent_spec.rb b/spec/indent/indent_spec.rb index 8ee78a6..cd37f1f 100644 --- a/spec/indent/indent_spec.rb +++ b/spec/indent/indent_spec.rb @@ -198,6 +198,20 @@ shared_examples_for "vim" do end end + describe "when using a function definition" do + it "indents shiftwidth spaces" do + vim.feedkeys 'idef long_function_name(\arg' + indent.should == shiftwidth * 2 + end + end + + describe "when using a class definition" do + it "indents shiftwidth spaces" do + vim.feedkeys 'iclass Foo(\' + indent.should == shiftwidth * 2 + end + end + describe "when writing an 'else' block" do it "aligns to the preceeding 'for' block" do vim.feedkeys 'ifor x in "abc":\pass\else:'