Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Add documentation and bug reporting commands from `clojure-mode`.
- [#118](https://github.com/clojure-emacs/clojure-ts-mode/pull/118): Add some ns manipulation functions from `clojure-mode`.
- Fix a bug in `clojure-ts-add-arity` when body has more than one expression.
- [#120](https://github.com/clojure-emacs/clojure-ts-mode/issues/120): Fix a bug when symbols with metadata were not listed in imenu.

## 0.5.1 (2025-06-17)

Expand Down
11 changes: 4 additions & 7 deletions clojure-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -1003,13 +1003,10 @@ If there is no namespace, returns nil."
(defun clojure-ts--node-child-skip-metadata (node n)
"Return the Nth child of NODE like `treesit-node-child', sans metadata.
Skip the optional metadata node at pos 0 if present."
(let ((first-child (treesit-node-child node 0 t)))
(treesit-node-child
node
(if (clojure-ts--metadata-node-p first-child)
(1+ n)
n)
t)))
(let ((value-nodes (thread-last (treesit-node-children node t)
(seq-filter (lambda (child)
(string= (treesit-node-field-name child) "value"))))))
(seq-elt value-nodes n)))

(defun clojure-ts--first-value-child (node)
"Return the first value child of the given NODE.
Expand Down
6 changes: 6 additions & 0 deletions test/clojure-ts-mode-imenu-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
(expect (imenu-find-default "a" flatten-index)
:to-equal "Variable:a"))))

(it "should index def with meta data before symbol"
(with-clojure-ts-buffer "(def ^:private a 1)"
(let ((flatten-index (imenu--flatten-index-alist (imenu--make-index-alist) t)))
(expect (imenu-find-default "a" flatten-index)
:to-equal "Variable:a"))))

(it "should index defn with meta data"
(with-clojure-ts-buffer "^{:foo 1}(defn a [])"
(let ((flatten-index (imenu--flatten-index-alist (imenu--make-index-alist) t)))
Expand Down