From 1acdb2f128fdae6f30efae6b1c1fe6526e145fea Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Sun, 24 Aug 2014 18:35:48 -0700 Subject: [PATCH] Fix square bracket indents --- example/example.swift | 8 ++++++++ indent/swift.vim | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/example/example.swift b/example/example.swift index b8a14bd..4f1eda2 100644 --- a/example/example.swift +++ b/example/example.swift @@ -255,3 +255,11 @@ func foo () { let foo = CGRectMake(0, (5 - 2), 100, 200) + + +let dict = [ + "foo": "Bar", + "nest": [ + "fadsf", + ], +] diff --git a/indent/swift.vim b/indent/swift.vim index 9432643..1f92089 100644 --- a/indent/swift.vim +++ b/indent/swift.vim @@ -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)