Skip to content

Commit d19b456

Browse files
JelteFblueyed
authored andcommitted
Indent dictionary values on a new line extra
1 parent d9efc96 commit d19b456

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

indent/python.vim

+6
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ function! s:indent_like_opening_paren(lnum)
217217
return res + s:sw()
218218
endif
219219
endif
220+
221+
" Indent by one level with colon on previous line (dictionary keys).
222+
if getline(a:lnum-1) =~# ':\s*$'
223+
let res = res + s:sw()
224+
endif
225+
220226
return res
221227
endfunction
222228

spec/indent/indent_spec.rb

+16
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@
9090
end
9191
end
9292

93+
describe "after a dictionary key" do
94+
before { vim.feedkeys 'imydict = {"12345": ' }
95+
96+
it "indents to opening paren + shiftwidth" do
97+
vim.feedkeys '\<CR>'
98+
indent.should == 10 + shiftwidth
99+
end
100+
it "on a new line indents to opening paren + shiftwidth" do
101+
vim.feedkeys '123,\<CR>"4567": '
102+
indent.should == 10
103+
vim.feedkeys '\<CR>'
104+
indent.should == 10 + shiftwidth
105+
end
106+
end
107+
108+
93109
describe "when using gq to reindent a '(' that is" do
94110
before { vim.feedkeys 'itest(' }
95111
it "something and has a string without spaces at the end" do

0 commit comments

Comments
 (0)