Skip to content

Commit d097670

Browse files
committed
Provide ability to specify right click actions if there is no item
1 parent 4faf0e3 commit d097670

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lsp-treemacs.el

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,7 @@
909909
(symbol-name (read (url-unhex-string jar-file )))))
910910

911911
(defvar-local lsp-treemacs-tree nil)
912+
(defvar-local lsp-treemacs--right-click-actions nil)
912913

913914
(defun lsp-treemacs-perform-ret-action (&rest _)
914915
(interactive)
@@ -1102,9 +1103,9 @@
11021103
(run-with-idle-timer
11031104
0.001 nil
11041105
(lambda ()
1105-
(-when-let* ((actions (-some-> (treemacs-node-at-point)
1106-
(button-get :item)
1107-
(plist-get :actions)))
1106+
(-when-let* ((actions (if-let (node (treemacs-node-at-point))
1107+
(plist-get (button-get node :item) :actions)
1108+
lsp-treemacs--right-click-actions))
11081109
(menu (easy-menu-create-menu nil actions))
11091110
(choice (x-popup-menu event menu)))
11101111
(when choice (call-interactively (lookup-key menu (apply 'vector choice))))
@@ -1147,11 +1148,12 @@
11471148
(interactive)
11481149
(lsp-treemacs--open-file-in-mru path)))))))
11491150

1150-
(defun lsp-treemacs-render (tree title expand? &optional buffer-name)
1151+
(defun lsp-treemacs-render (tree title expand? &optional buffer-name right-click-actions)
11511152
(let ((search-buffer (get-buffer-create (or buffer-name "*LSP Lookup*"))))
11521153
(with-current-buffer search-buffer
11531154
(lsp-treemacs-initialize)
11541155
(setq-local treemacs-default-visit-action 'treemacs-RET-action)
1156+
(setq-local lsp-treemacs--right-click-actions right-click-actions)
11551157
(setq-local lsp-treemacs--generic-cache (or lsp-treemacs--generic-cache (ht)))
11561158
(setq-local lsp-treemacs-tree tree)
11571159
(setq-local face-remapping-alist '((button . default)))
@@ -1188,8 +1190,8 @@ depending on if a custom mode line is detected."
11881190
(lsp-with-cached-filetrue-name
11891191
(let ((lsp-file-truename-cache (ht)))
11901192
(lsp-treemacs-render (lsp-treemacs--handle-references refs)
1191-
(format title (length refs))
1192-
expand?)))
1193+
(format title (length refs))
1194+
expand?)))
11931195
(lsp--info "Refresh completed!"))
11941196
:mode 'detached
11951197
:cancel-token :treemacs-lookup)

0 commit comments

Comments
 (0)