[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars 9740b6ff4a 227/431: Add min-lines support f
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars 9740b6ff4a 227/431: Add min-lines support for scope |
Date: |
Mon, 16 Sep 2024 12:59:31 -0400 (EDT) |
branch: externals/indent-bars
commit 9740b6ff4a3cc504a63baa26730483c7208ad9b8
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Add min-lines support for scope
---
indent-bars-ts.el | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/indent-bars-ts.el b/indent-bars-ts.el
index 04c6726077..62f0e36060 100644
--- a/indent-bars-ts.el
+++ b/indent-bars-ts.el
@@ -80,6 +80,10 @@ variables."
:value-type (repeat :tag "Types" (symbol :tag "Type"))))
:group 'indent-bars-ts)
+(defcustom indent-bars-treesit-scope-min-lines 2
+ "Minimum number of lines a node must span to be counted for scope."
+ :type 'integer)
+
(defcustom indent-bars-treesit-ignore-blank-lines-types nil
"Do not style blank lines when the type of node at start is in this list.
Either nil, or a list of node type strings to avoid adding blank
@@ -120,7 +124,8 @@ Otherwise return nil."
(>= (treesit-node-end node) end)
node))
-(defun indent-bars-ts--node-query (node query &optional start-only spanning)
+(defun indent-bars-ts--node-query (node query &optional
+ start-only spanning min-newlines)
"Capture node(s) matching QUERY which overlap with NODE.
QUERY is a compiled treesit query. If START-ONLY is non-nil, the
query searches for matching nodes which overlap with NODE's
@@ -133,19 +138,32 @@ START-ONLY is non-nil). If SPANNING is \\='innermost,
return the
latest (innermost) node on the list which fully spans NODE, which
could include NODE itself if it matches the QUERY. For any other
non-nil value of SPANNING, check if the first node matched by
-QUERY spans NODE and return it if so. If no spanning node is
-found, nil is returned."
+QUERY spans NODE and return it if so. If MIN-NEWLINES is a
+number, a spanning node will be returned only if spans at least
+that many newlines. E.g. MIN-NEWLINES=1 demands a two line
+node (or larger).
+
+If no spanning node is found, nil is returned."
(when-let ((start (treesit-node-start node))
(end (if start-only start (treesit-node-end node)))
(nodes (treesit-query-capture indent-bars-ts--parser query
start end t)))
(cond ((eq spanning 'innermost)
(cl-loop for n in (nreverse nodes)
- if (or (eq n node)
- (indent-bars-ts--node-spans-p n start end))
+ if (and (or (eq n node)
+ (indent-bars-ts--node-spans-p n start end))
+ (or (not min-newlines)
+ (>= (count-lines
+ (treesit-node-start n) (treesit-node-end
n))
+ min-newlines)))
return n))
(spanning ; check first node, if it doesn't span, none will
- (indent-bars-ts--node-spans-p (car nodes) start end))
+ (when-let ((n (indent-bars-ts--node-spans-p (car nodes) start end))
+ ((or (not min-newlines)
+ (>= (count-lines
+ (treesit-node-start n) (treesit-node-end n))
+ min-newlines))))
+ n))
(t nodes))))
(defsubst indent-bars--indent-at-node (node)
@@ -276,7 +294,8 @@ both)."
(max (point-min) (1- (point))) (point)
indent-bars-ts--parser))
(scope (indent-bars-ts--node-query
- node (ibts/query ibtcs) nil 'innermost)))
+ node (ibts/query ibtcs) nil 'innermost
+ indent-bars-treesit-scope-min-lines)))
(let ((old-start (ibts/start ibtcs))
(old-end (ibts/end ibtcs))
(tsc-start (treesit-node-start scope))
- [elpa] externals/indent-bars 20e34365e9 191/431: ts: improved query setup, (continued)
- [elpa] externals/indent-bars 20e34365e9 191/431: ts: improved query setup, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 2e0e6ee0fd 196/431: add support for ts start-bars to switch from oos to emph w/in line, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars a4d43c0054 163/431: README: FAQ starting-column, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 7b6454d6e8 190/431: ts.el: improve docs and customization options, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f5d9426fe6 199/431: overhaul style-system: pass-by-arg, switch-after, style2, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 9f2b7625b4 212/431: scope-update: reference correct timer, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 28cc7f4a82 216/431: Use "ts" alt style uniformly, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 2889b50077 224/431: Always initialize style on scope init, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 230e3c8377 221/431: setup-and-remove: wrap in with-selected-frame, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 1b6e353634 225/431: Correctly track separate stipple face for each style, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 9740b6ff4a 227/431: Add min-lines support for scope,
ELPA Syncer <=
- [elpa] externals/indent-bars 09dd1d6f75 209/431: Correct after-make-frame handling for daemon, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 226b6c2dd0 226/431: custom-inherit: correctly handle 'unspecified atoms, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars dbbd7fb1ed 218/431: Add (custom-inherit): Improve inheritance for partial plists, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b8319cf7d4 237/431: add support for json-ts-mode and json-mode, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 4ad704782a 233/431: Properly handle SWITCH-AFTER=0, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 7acbd9124b 235/431: README: Acknowledgements, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 117121cbd6 230/431: Guard update-scope against non-mode buffers, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars cd463afdbc 223/431: Use union of old and new ranges, not symdiff, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 48646b1123 234/431: README: Acknowledgements, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 2ee5157b41 244/431: Require 'subr-x for hash functions, ELPA Syncer, 2024/09/16