Skip to content

Commit 518fd84

Browse files
authored
Merge pull request #42 from MetaDark/master
Added depth argument to lsp-treemacs--expand
2 parents bd2c372 + 5a2a779 commit 518fd84

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lsp-treemacs.el

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,10 @@
612612
(add-to-list 'winum-ignored-buffers "*LSP Error List*")
613613
(add-to-list 'winum-ignored-buffers lsp-treemacs-deps-buffer-name)))
614614

615-
(defun lsp-treemacs--expand (root-key)
615+
(defun lsp-treemacs--expand (root-key depth)
616616
(-when-let (root (treemacs-dom-node->position (treemacs-find-in-dom root-key)))
617617
(treemacs-save-position
618-
(lsp-treemacs--expand-recursively root))))
618+
(lsp-treemacs--expand-recursively root depth))))
619619

620620
(defun lsp-treemacs--kill-symbols-buffer ()
621621
(and lsp-treemacs--symbols-timer (cancel-timer lsp-treemacs--symbols-timer)))
@@ -637,15 +637,16 @@
637637
(add-hook 'kill-buffer-hook 'lsp-treemacs--kill-symbols-buffer nil t)))
638638
(with-current-buffer original-buffer (lsp-treemacs--update))))
639639

640-
(defun lsp-treemacs--expand-recursively (root)
641-
(save-excursion
642-
(-map
643-
(lambda (btn)
644-
(unless (treemacs-is-node-expanded? btn)
645-
(goto-char (marker-position btn))
646-
(funcall (alist-get (treemacs-button-get btn :state) treemacs-TAB-actions-config)))
647-
(lsp-treemacs--expand-recursively btn))
648-
(treemacs--get-children-of root))))
640+
(defun lsp-treemacs--expand-recursively (root depth)
641+
(when (if (booleanp depth) depth (not (zerop depth)))
642+
(save-excursion
643+
(-map
644+
(lambda (btn)
645+
(unless (treemacs-is-node-expanded? btn)
646+
(goto-char (marker-position btn))
647+
(funcall (alist-get (treemacs-button-get btn :state) treemacs-TAB-actions-config)))
648+
(lsp-treemacs--expand-recursively btn (if (booleanp depth) depth (1- depth))))
649+
(treemacs--get-children-of root)))))
649650

650651

651652
(defmacro lsp-treemacs-deps-with-jdtls (&rest body)
@@ -1159,7 +1160,7 @@
11591160
,@body)
11601161
(treemacs-pulse-on-failure "No node at point"))))
11611162

1162-
(defun lsp-treemacs-render (tree title expand? &optional buffer-name right-click-actions)
1163+
(defun lsp-treemacs-render (tree title expand-depth &optional buffer-name right-click-actions)
11631164
(let ((search-buffer (get-buffer-create (or buffer-name "*LSP Lookup*"))))
11641165
(with-current-buffer search-buffer
11651166
(lsp-treemacs-initialize)
@@ -1170,7 +1171,7 @@
11701171
(setq-local face-remapping-alist '((button . default)))
11711172
(lsp-treemacs--set-mode-line-format search-buffer title)
11721173
(lsp-treemacs-generic-refresh)
1173-
(when expand? (lsp-treemacs--expand 'LSP-Generic))
1174+
(lsp-treemacs--expand 'LSP-Generic expand-depth)
11741175
(current-buffer))))
11751176

11761177
(defalias 'lsp-treemacs--show-references 'lsp-treemacs-render)

0 commit comments

Comments
 (0)