[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 07f6434 111/496: Fix indentation issues with ty
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 07f6434 111/496: Fix indentation issues with type annotations |
Date: |
Sun, 29 Aug 2021 11:33:18 -0400 (EDT) |
branch: elpa/swift-mode
commit 07f643479789ef219ad3e3d009e641ad954363f9
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>
Fix indentation issues with type annotations
---
swift-mode.el | 10 +++++++++-
test/indentation-tests.el | 49 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/swift-mode.el b/swift-mode.el
index bee995e..ac810cd 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -66,7 +66,7 @@
(smie-merge-prec2s
(smie-bnf->prec2
'((id)
- (type)
+ (type (type) (type "<T" types "T>"))
(types (type) (type "," type))
(class-decl-exp (id) (id ":" types))
@@ -194,6 +194,10 @@
";")
((looking-at "{") (forward-char 1) "{")
((looking-at "}") (forward-char 1) "}")
+ ((looking-at "<") (forward-char 1)
+ (if (looking-at "[[:upper:]]") "<T" "OP"))
+ ((looking-at ">") (forward-char 1)
+ (if (looking-back "[[:space:]]>" 2 t) "OP" "T>"))
((looking-at swift-smie--operators-regexp)
(goto-char (match-end 0)) "OP")
((looking-at swift-smie--decl-specifier-regexp)
@@ -209,6 +213,10 @@
";")
((eq (char-before) ?\{) (backward-char 1) "{")
((eq (char-before) ?\}) (backward-char 1) "}")
+ ((eq (char-before) ?<) (backward-char 1)
+ (if (looking-at "<[[:upper:]]") "<T" "OP"))
+ ((eq (char-before) ?>) (backward-char 1)
+ (if (looking-back "[[:space:]]" 1 t) "OP" "T>"))
((looking-back swift-smie--operators-regexp (- (point) 3) t)
(goto-char (match-beginning 0)) "OP")
((looking-back swift-smie--decl-specifier-regexp (- (point) 8) t)
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 24c8b72..4c9152a 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -721,6 +721,55 @@ let foo = [
]
")
+(check-indentation indents-declaration/7
+ "
+var result = Dictionary<String, V>()
+ |foo
+" "
+var result = Dictionary<String, V>()
+|foo
+")
+
+(check-indentation indents-type-annotations/1
+ "
+typealias Foo = Bar<Foo.Baz, Foo>
+ |foo
+" "
+typealias Foo = Bar<Foo.Baz, Foo>
+|foo
+")
+
+(check-indentation indents-type-annotations/2
+ "
+typealias Foo = Bar<Foo.Baz,
+|Foo>
+" "
+typealias Foo = Bar<Foo.Baz,
+ |Foo>
+")
+
+(check-indentation indents-type-works-with-less-operator/1
+ "
+typealias Foo = Bar<Foo.Baz, Foo>
+let foo = bar <
+|baz
+" "
+typealias Foo = Bar<Foo.Baz, Foo>
+let foo = bar <
+ |baz
+")
+
+(check-indentation indents-type-works-with-less-operator/2
+ "
+typealias Foo = Bar<Foo.Baz, Foo>
+let foo = bar >
+|baz
+" "
+typealias Foo = Bar<Foo.Baz, Foo>
+let foo = bar >
+ |baz
+")
+
(provide 'indentation-tests)
;;; indentation-tests.el ends here
- [nongnu] elpa/swift-mode 4a5f577 488/496: Tweak comments and style, (continued)
- [nongnu] elpa/swift-mode 4a5f577 488/496: Tweak comments and style, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 86043c2 093/496: Define electric-indent characters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b298842 094/496: Merge pull request #26 from ap4y/electric_indent, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 027522d 090/496: Merge pull request #23 from ap4y/flycheck_improvements, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 20e4ecf 099/496: Merge pull request #27 from ap4y/highlight_declaration_with_destructuring, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 53f9042 100/496: Rename swift-mode--font-lock-defaults to swift-font-lock-keywords and, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 72eb603 105/496: Use semver friendly version number, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 021f0ab 104/496: Remove flycheck code from .dir-locals.el as not everyone has flycheck installed, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0c734dd 112/496: Indent multiline hash and array syntax same way as Xcode does, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 699e896 106/496: Start work on the 0.2 series, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 07f6434 111/496: Fix indentation issues with type annotations,
ELPA Syncer <=
- [nongnu] elpa/swift-mode abd6e07 130/496: Merge pull request #39 from ap4y/fix_37, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c664fc2 144/496: Merge pull request #51 from ap4y/fix_default_case_indentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ce72472 141/496: Make all possible operators allowed in string interpolation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3298fb1 169/496: Stop overriding user preferences for tab-width., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0808a2b 170/496: Add font-lock rules for access modifier keywords, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 52045f0 174/496: Fix issues with several failing tests on emacs 24.4, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 230afd3 175/496: Setup travis matrix with emacs 24.3 and 24.4., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5fabebd 196/496: Improve indentation rules for function arguments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 38933b9 208/496: Don't use implicit semicolon when operator is placed on the second line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d0c65bc 212/496: Fix bug with the closing parentheses in method calls and function, ELPA Syncer, 2021/08/29