branch: elpa/swift-mode
commit a6267ebec3cdb516cb5bb2ae8ca08984beca050e
Author: ap4y <[email protected]>
Commit: ap4y <[email protected]>
Improve indentation for the function definitions
---
swift-mode.el | 5 ++++-
test/indentation-tests.el | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 193e9be..3f638b1 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -336,7 +336,10 @@
(`(:before . "(")
(if (smie-rule-next-p "[") (smie-rule-parent)))
- (`(:before . "[") (smie-rule-parent))
+ (`(:before . "[")
+ (if (smie-rule-prev-p "->") swift-indent-offset
+ (smie-rule-parent)))
+ (`(:after . "->") swift-indent-offset)
))
;;; Font lock
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 4a2ebc1..c0b5d61 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -747,7 +747,7 @@ class Foo {
}
")
-(check-indentation indents-func-declaration/2
+(check-indentation indents-func-declaration/5
"
class func Foo() {
|foo
@@ -758,6 +758,43 @@ class func Foo() {
}
")
+(check-indentation indents-func-declaration/6
+ "
+func Foo(aaaaaaaaa:
+ |AAAAAAAAA) {
+}
+" "
+func Foo(aaaaaaaaa:
+ |AAAAAAAAA) {
+}
+")
+
+(check-indentation indents-func-declaration/7
+ "
+func foo() ->
+|Foo
+" "
+func foo() ->
+ |Foo
+")
+
+(check-indentation indents-func-declaration/8
+ "
+func foo() ->
+|(A, B) {}
+" "
+func foo() ->
+ |(A, B) {}
+")
+
+(check-indentation indents-func-declaration/9
+ "
+func foo() ->
+|[A] {}
+" "
+func foo() ->
+ |[A] {}
+")
(check-indentation indents-declaration/1
"
var foo = bar + baz