[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/clojure-ts-mode 85871fdbc8 03/14: Match threading alignmen
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/clojure-ts-mode 85871fdbc8 03/14: Match threading alignment of cljfmt, clojure-mode |
Date: |
Fri, 8 Sep 2023 18:59:17 -0400 (EDT) |
branch: elpa/clojure-ts-mode
commit 85871fdbc831b3129dae5762e9c247d453c35e15
Author: dannyfreeman <danny@dfreeman.email>
Commit: Danny Freeman <danny@dfreeman.email>
Match threading alignment of cljfmt, clojure-mode
(->> asdf
foo
bar)
and
(->>
asdf
foo
bar)
when first thing is not on line with the threading symbol
---
clojure-ts-mode.el | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/clojure-ts-mode.el b/clojure-ts-mode.el
index e7ec1f06a1..4b47f45af6 100644
--- a/clojure-ts-mode.el
+++ b/clojure-ts-mode.el
@@ -617,15 +617,29 @@ See `treesit-simple-indent-rules'."
(rx (and "->" (? ">") line-end)))
"A regular expression matching a threading macro.")
-(defun clojure-ts--threading-macro-p (node)
- "Return non-nil if NODE is a threading macro symbol like ->>."
- (clojure-ts--symbol-matches-p clojure-ts--threading-macro node))
+(defun clojure-ts--match-threading-macro-arg (_node parent _)
+ "Match NODE if it is an argument to a PARENT threading macro."
+ ;; We want threading macros to indent 2 only if the ->> is on it's own line.
+ ;; If not, then align functoin arg.
+ (and (clojure-ts--list-node-p parent)
+ (let ((first-child (treesit-node-child parent 0 t)))
+ (clojure-ts--symbol-matches-p
+ clojure-ts--threading-macro
+ first-child))))
+
+(defun clojure-ts--threading-macro-arg-offset (node _parent _bol)
+ "Calculates the indentation offset for NODE, a threading macro argument."
+ (if (and node (<= (treesit-node-index node t) 1))
+ 1 ;; NODE is the first arg, offset 1 from start of *->> symbol
+ 0)) ;; arg 2...n, match indentation of the previous argument
(defvar clojure-ts--semantic-indent-rules
`((clojure
((parent-is "source") parent-bol 0)
;; https://guide.clojure.style/#body-indentation
(clojure-ts--match-expression-in-body parent 2)
+ ;; https://guide.clojure.style/#threading-macros-alignment
+ (clojure-ts--match-threading-macro-arg prev-sibling 0)
;; https://guide.clojure.style/#vertically-align-fn-args
(clojure-ts--match-function-call-arg (nth-sibling 2 nil) 0)
;; Literal Sequences
- [nongnu] elpa/clojure-ts-mode updated (2225190ee5 -> 881756c8f5), ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode ae2e248601 01/14: First pass at semantic indentation, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode ca3914aa7a 02/14: Name inline indent helper functions instead of using lambdas, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode ff5d7e13dc 05/14: Semantic indentation of method implementations, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode b6f6d37959 10/14: Update changelog to include information about semantic indentation, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode a8a321500e 13/14: More documentation updates, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode 85871fdbc8 03/14: Match threading alignment of cljfmt, clojure-mode,
ELPA Syncer <=
- [nongnu] elpa/clojure-ts-mode 64d8fde253 04/14: Semantic indentation docs, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode a87821629f 07/14: Fix docstring font-locking, try to clarify various regex names, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode 0c4bd2bfce 06/14: Indent example file, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode d4e0f1ae44 09/14: Move thing-settings out of the middle of indent-related functions, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode 177ac05434 08/14: Indent within docstrings - not working 100%, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode 1675f12e26 12/14: Unused argument causing linter to fail, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode 881756c8f5 14/14: Remove unused function, ELPA Syncer, 2023/09/08
- [nongnu] elpa/clojure-ts-mode 211dc1452b 11/14: Update README docs to include new configuration options, ELPA Syncer, 2023/09/08