[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/indent-bars 880236eb59 115/431: Use a compiled query-ca
From: |
ELPA Syncer |
Subject: |
[elpa] externals/indent-bars 880236eb59 115/431: Use a compiled query-capture to find uppermost containing list |
Date: |
Mon, 16 Sep 2024 12:59:19 -0400 (EDT) |
branch: externals/indent-bars
commit 880236eb592f801791f8da32c7545f6a5158ff09
Author: JD Smith <93749+jdtsmith@users.noreply.github.com>
Commit: JD Smith <93749+jdtsmith@users.noreply.github.com>
Use a compiled query-capture to find uppermost containing list
indentation level should be based on the start line of the topmost
containing node which matches inside indent-bars-treesit-support.
This gets that quite quickly.
---
indent-bars.el | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/indent-bars.el b/indent-bars.el
index 201a1e75a8..f901bcbda0 100644
--- a/indent-bars.el
+++ b/indent-bars.el
@@ -712,14 +712,8 @@ returned."
nil)
;;;; Tree-sitter
-(defvar-local indent-bars--ts-node-types nil)
(defvar-local indent-bars--ts-lang nil)
-
-(defun indent-bars--treesit-node-match (n)
- "Return if node N has matching type, nil otherwise.
-The TYPES are as configured in `indent-bars-treesit-support'."
- (seq-contains-p indent-bars--ts-node-types
- (treesit-node-type n) #'string=))
+(defvar-local indent-bars--ts-query nil)
(defvar indent-bars--string-content "string_content")
(defsubst indent-bars--indent-at-node (node)
@@ -744,9 +738,11 @@ starting line's depth."
(if (and indent-bars-no-descend-string
(string= (treesit-node-type node) indent-bars--string-content))
(min d (1+ (/ (indent-bars--indent-at-node node)
indent-bars-spacing)))
- (if-let ((indent-bars--ts-node-types)
- (ctx (treesit-parent-until node
#'indent-bars--treesit-node-match t)))
- (min d (1+ (/ (indent-bars--indent-at-node ctx)
indent-bars-spacing)))))
+ (if-let ((indent-bars--ts-query)
+ (ctx (treesit-query-capture
+ indent-bars--ts-lang indent-bars--ts-query
+ (treesit-node-start node) (treesit-node-end node) t)))
+ (min d (1+ (/ (indent-bars--indent-at-node (car ctx))
indent-bars-spacing)))))
d))))
;;;; No stipple (e.g. terminal)
@@ -1027,7 +1023,8 @@ Adapted from `highlight-indentation-mode'."
(lang (treesit-language-at (point-min)))
(types (alist-get lang indent-bars-treesit-support)))
(setq indent-bars--ts-lang lang
- indent-bars--ts-node-types types))
+ indent-bars--ts-query
+ (treesit-query-compile lang `([,@(mapcar #'list types)] @ctx))))
;; Current depth highlight
(when indent-bars-highlight-current-depth
@@ -1060,7 +1057,8 @@ Adapted from `highlight-indentation-mode'."
indent-bars--current-depth-stipple nil
indent-bars--no-stipple-chars nil
indent-bars--current-bg-color nil
- indent-bars--current-depth 0)
+ indent-bars--current-depth 0
+ indent-bars--ts-query nil)
(remove-hook 'text-scale-mode-hook #'indent-bars--resize-stipple t)
(remove-hook 'post-command-hook #'indent-bars--highlight-current-depth t)
(remove-hook 'font-lock-extend-region-functions
- [elpa] externals/indent-bars 09a3fd2492 080/431: Update README.md, (continued)
- [elpa] externals/indent-bars 09a3fd2492 080/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars a1718333ab 116/431: Fix indent-bars-treesit-support custom, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f5b61dad71 075/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 3bffb21456 111/431: Correct custom name for no-descend-string, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars f9558953b2 083/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 674b9d4b75 073/431: bump version, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 138bbab23f 106/431: Update examples.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars cc1a3143cb 113/431: Calc blank line current-indent at beginning of prior line, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 6192a63abe 066/431: README: fix stipple test, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 0ce041ed59 084/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 880236eb59 115/431: Use a compiled query-capture to find uppermost containing list,
ELPA Syncer <=
- [elpa] externals/indent-bars 30a4a63f11 138/431: highlight-current-depth: use new ON-BAR capability for depth, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 7957d7a2d3 135/431: draw-line: handle 1 bar case correctly, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars bb857e344f 126/431: Use starting-column instead of a fixed spacing offset, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 3249aafe0d 152/431: Improve whatsnew, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars 0638ba1ace 168/431: Customize the font weight of the no-stipple character, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars b0ba6ba4ba 147/431: handle-blank-lines: simplify, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars aa3d09ceff 173/431: Update README.md, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars e2a0274e8b 164/431: Make no-descend-string a local symbol for configuring string type, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars dca608724d 183/431: README: mention new depth highlight timer and config, ELPA Syncer, 2024/09/16
- [elpa] externals/indent-bars a618015bb5 145/431: Add treesit before/after images, ELPA Syncer, 2024/09/16