diff --git a/indent/python.vim b/indent/python.vim index 8fb5a9b..5acc9b4 100644 --- a/indent/python.vim +++ b/indent/python.vim @@ -217,6 +217,12 @@ function! s:indent_like_opening_paren(lnum) return res + s:sw() endif endif + + " Indent by one level with colon on previous line (dictionary keys). + if getline(a:lnum-1) =~# ':\s*$' + let res = res + s:sw() + endif + return res endfunction diff --git a/spec/indent/indent_spec.rb b/spec/indent/indent_spec.rb index 400ec11..2ef88f3 100644 --- a/spec/indent/indent_spec.rb +++ b/spec/indent/indent_spec.rb @@ -90,6 +90,22 @@ end end + describe "after a dictionary key" do + before { vim.feedkeys 'imydict = {"12345": ' } + + it "indents to opening paren + shiftwidth" do + vim.feedkeys '\' + indent.should == 10 + shiftwidth + end + it "on a new line indents to opening paren + shiftwidth" do + vim.feedkeys '123,\"4567": ' + indent.should == 10 + vim.feedkeys '\' + indent.should == 10 + shiftwidth + end + end + + describe "when using gq to reindent a '(' that is" do before { vim.feedkeys 'itest(' } it "something and has a string without spaces at the end" do