Skip to content

Commit

Permalink
Indent dictionary values on a new line extra
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF authored and blueyed committed Jul 26, 2018
1 parent d9efc96 commit d19b456
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions indent/python.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions spec/indent/indent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 '\<CR>'
indent.should == 10 + shiftwidth
end
it "on a new line indents to opening paren + shiftwidth" do
vim.feedkeys '123,\<CR>"4567": '
indent.should == 10
vim.feedkeys '\<CR>'
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
Expand Down

0 comments on commit d19b456

Please sign in to comment.