Fix square bracket indents

This commit is contained in:
Keith Smiley
2014-08-24 18:35:48 -07:00
parent edcbcd7bcb
commit 1acdb2f128
2 changed files with 13 additions and 0 deletions

View File

@@ -255,3 +255,11 @@ func foo () {
let foo = CGRectMake(0, (5 - 2),
100,
200)
let dict = [
"foo": "Bar",
"nest": [
"fadsf",
],
]

View File

@@ -12,6 +12,7 @@ let s:cpo_save = &cpo
set cpo&vim
setlocal indentexpr=SwiftIndent()
setlocal indentkeys+=0[,0]
function! s:NumberOfMatches(char, string)
let regex = "[^" . a:char . "]"
@@ -31,6 +32,10 @@ function! SwiftIndent()
return indent(previousNum) + &tabstop
endif
if line =~ "^\\s*],\\?$"
return indent(previousNum) - &tabstop
endif
" Indent multi line declarations see #19
" Allow statements to also be in parens
let numOpenParens = s:NumberOfMatches("(", previous)