@@ -133,6 +133,17 @@ double quotes on the third column."
133
133
:type 'boolean
134
134
:package-version '(clojure-ts-mode . " 0.3" ))
135
135
136
+ (defcustom clojure-ts-outline-variant 'comments
137
+ " Determines how `clojure-ts-mode' integrates with `outline-minor-mode' .
138
+
139
+ If set to the symbol `comments' , then top-level comments starting with
140
+ three or more semicolons will be treated as outline headings. If set to
141
+ `imenu' , then def-like forms are treated as outline headings."
142
+ :safe #'symbolp
143
+ :type '(choice (const :tag " Use special comments" comments)
144
+ (const :tag " Use imenu" imenu))
145
+ :package-version '(clojure-ts-mode . " 0.4" ))
146
+
136
147
(defcustom clojure-ts-align-reader-conditionals nil
137
148
" Whether to align reader conditionals, as if they were maps."
138
149
:package-version '(clojure-ts-mode . " 0.4" )
@@ -913,6 +924,20 @@ Includes a dispatch value when applicable (defmethods)."
913
924
By default `treesit-defun-name-function' is used to extract definition names.
914
925
See `clojure-ts--standard-definition-node-name' for the implementation used." )
915
926
927
+ ; ;; Outline settings
928
+
929
+ (defun clojure-ts--outline-predicate (node )
930
+ " Return TRUE if NODE is an outline heading comment."
931
+ (and (string= (treesit-node-type node) " comment" )
932
+ (string-match-p " ^\\ (?:;;;;* \\ ).*" (treesit-node-text node))))
933
+
934
+ (defun clojure-ts--outline-level ()
935
+ " Return the current level of the outline heading at point."
936
+ (let* ((node (treesit-outline--at-point))
937
+ (node-text (treesit-node-text node)))
938
+ (string-match " ;;\\ (;+\\ ) " node-text)
939
+ (- (match-end 1 ) (match-beginning 1 ))))
940
+
916
941
(defcustom clojure-ts-indent-style 'semantic
917
942
" Automatic indentation style to use when mode `clojure-ts-mode' is run.
918
943
@@ -1708,6 +1733,13 @@ REGEX-AVAILABLE."
1708
1733
(setq-local indent-tabs-mode nil )
1709
1734
(setq-local comment-add 1 )
1710
1735
(setq-local comment-start " ;" )
1736
+ (when (equal clojure-ts-outline-variant 'comments )
1737
+ ; ; NOTE: If `imenu' option is selected for `clojure-ts-outline-variant' , all
1738
+ ; ; necessary variables will be set automatically by
1739
+ ; ; `treesit-major-mode-setup' .
1740
+ (setq-local treesit-outline-predicate #'clojure-ts--outline-predicate
1741
+ outline-search-function #'treesit-outline-search
1742
+ outline-level #'clojure-ts--outline-level ))
1711
1743
1712
1744
(setq-local treesit-font-lock-settings
1713
1745
(clojure-ts--font-lock-settings markdown-available regex-available))
0 commit comments