mirror of
https://github.com/keith/swift.vim.git
synced 2025-12-17 12:00:25 +01:00
Fix square bracket indents
This commit is contained in:
@@ -255,3 +255,11 @@ func foo () {
|
||||
let foo = CGRectMake(0, (5 - 2),
|
||||
100,
|
||||
200)
|
||||
|
||||
|
||||
let dict = [
|
||||
"foo": "Bar",
|
||||
"nest": [
|
||||
"fadsf",
|
||||
],
|
||||
]
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user