From a946371787067299e53338857b792005b84d8962 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 6 May 2015 18:07:18 +0200 Subject: [PATCH] Add more indentation after function/class definition Fixes https://github.com/hynek/vim-python-pep8-indent/issues/30 --- indent/python.vim | 2 +- spec/indent/indent_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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:' -- 2.39.5