414414 (treemacs-create-icon :file " package.png" :extensions (package ) :fallback " -" )
415415 (treemacs-create-icon :file " project.png" :extensions (java-project) :fallback " -" )))
416416
417- (defun lsp-treemacs-- symbol-kind->icon (kind )
417+ (defun lsp-treemacs-symbol-kind->icon (kind )
418418 (cl-case kind
419419 (1 'document )
420420 (2 'namespace )
450450 (if (seq-empty-p children)
451451 " "
452452 (if expanded " ▾ " " ▸ " ))
453- (treemacs-get-icon-value (lsp-treemacs-- symbol-kind->icon kind)
453+ (treemacs-get-icon-value (lsp-treemacs-symbol-kind->icon kind)
454454 nil
455455 lsp-treemacs-theme))))
456456
512512 (when (string= parent-key container-name)
513513 `(:label , name
514514 :key , name
515- :icon ,(lsp-treemacs-- symbol-kind->icon kind)
515+ :icon ,(lsp-treemacs-symbol-kind->icon kind)
516516 ,@(when (-first (-lambda ((&hash " containerName" parent))
517517 (string= name parent))
518518 rest)
533533 (propertize name 'face 'lsp-face-semhl-deprecated )
534534 name)
535535 :key , name
536- :icon ,(lsp-treemacs-- symbol-kind->icon kind)
536+ :icon ,(lsp-treemacs-symbol-kind->icon kind)
537537 :kind , kind
538538 :location (gethash " start" range)
539539 ,@(unless (seq-empty-p children)
11481148 (interactive )
11491149 (lsp-treemacs--open-file-in-mru path)))))))
11501150
1151+ (defmacro lsp-treemacs-define-action (name keys &rest body )
1152+ (declare (doc-string 3 ) (indent 2 ))
1153+ `(defun , name (&rest args)
1154+ ,(format " Code action %s " name)
1155+ (interactive )
1156+ (if-let (node (treemacs-node-at-point))
1157+ (-let [,(cons '&plist keys) (button-get node :item )]
1158+ ,@body )
1159+ (treemacs-pulse-on-failure " No node at point" ))))
1160+
11511161(defun lsp-treemacs-render (tree title expand? &optional buffer-name right-click-actions )
11521162 (let ((search-buffer (get-buffer-create (or buffer-name " *LSP Lookup*" ))))
11531163 (with-current-buffer search-buffer
@@ -1180,8 +1190,7 @@ depending on if a custom mode line is detected."
11801190
11811191(defun lsp-treemacs--do-search (method params title prefix-args )
11821192 (let ((search-buffer (get-buffer-create " *LSP Lookup*" ))
1183- (window (display-buffer-in-side-window (get-buffer-create " *LSP Lookup*" )
1184- '((side . bottom)))))
1193+ (window (display-buffer (get-buffer-create " *LSP Lookup*" ))))
11851194 (lsp-request-async
11861195 method
11871196 params
@@ -1198,7 +1207,8 @@ depending on if a custom mode line is detected."
11981207
11991208 (unless (equal prefix-args 0 )
12001209 (select-window window)
1201- (set-window-dedicated-p window t ))
1210+ ; ; (set-window-dedicated-p window t)
1211+ )
12021212
12031213 (with-current-buffer search-buffer
12041214 (lsp-treemacs-initialize)
@@ -1230,62 +1240,62 @@ With a prefix argument, select the new window expand the tree of implementations
12301240; ; Call hierarchy.
12311241
12321242(defun lsp-treemacs--call-hierarchy-children (buffer method key node callback )
1233- (-let [item (plist-get node :item )]
1234- (with-current-buffer buffer
1235- (lsp-request-async
1236- method
1237- (list :item item)
1238- (lambda (result )
1239- (funcall
1240- callback
1241- (seq-map
1242- (-lambda ((node &as &hash key (child-item &as &hash " name"
1243- " kind" " detail" " selectionRange" (&hash " start" ) " uri" )))
1244- (let ((label (concat name (when detail
1245- (propertize (concat " - " detail) 'face 'lsp-lens-face )))))
1246- (list :label label
1247- :key label
1248- :icon (lsp-treemacs- -symbol-kind->icon kind)
1249- :children-async (-partial #'lsp-treemacs--call-hierarchy-children buffer method key)
1250- :ret-action (lambda (&rest _ )
1251- (interactive )
1252- (lsp-treemacs--open-file-in-mru (lsp--uri-to-path uri))
1253- (goto-char (lsp--position-to-point start))
1254- (run-hooks 'xref-after-jump-hook ))
1255- :item child-item)))
1256- result)))
1257- :mode 'detached ))))
1243+ (-let [item (plist-get node :item )]
1244+ (with-current-buffer buffer
1245+ (lsp-request-async
1246+ method
1247+ (list :item item)
1248+ (lambda (result )
1249+ (funcall
1250+ callback
1251+ (seq-map
1252+ (-lambda ((node &as &hash key (child-item &as &hash " name"
1253+ " kind" " detail" " selectionRange" (&hash " start" ) " uri" )))
1254+ (let ((label (concat name (when detail
1255+ (propertize (concat " - " detail) 'face 'lsp-lens-face )))))
1256+ (list :label label
1257+ :key label
1258+ :icon (lsp-treemacs-symbol-kind->icon kind)
1259+ :children-async (-partial #'lsp-treemacs--call-hierarchy-children buffer method key)
1260+ :ret-action (lambda (&rest _ )
1261+ (interactive )
1262+ (lsp-treemacs--open-file-in-mru (lsp--uri-to-path uri))
1263+ (goto-char (lsp--position-to-point start))
1264+ (run-hooks 'xref-after-jump-hook ))
1265+ :item child-item)))
1266+ result)))
1267+ :mode 'detached ))))
12581268
12591269;;;### autoload
12601270(defun lsp-treemacs-call-hierarchy (outgoing )
1261- " Show the incoming call hierarchy for the symbol at point.
1271+ " Show the incoming call hierarchy for the symbol at point.
12621272With a prefix argument, show the outgoing call hierarchy."
1263- (interactive " P" )
1264- (unless (lsp--find-workspaces-for " textDocument/prepareCallHierarchy" )
1265- (user-error " Call hierarchy not supported by the current servers: %s"
1266- (-map #'lsp--workspace-print (lsp-workspaces))))
1267- (let ((buffer (current-buffer )))
1268- (select-window
1269- (display-buffer-in-side-window
1270- (lsp-treemacs-render
1271- (seq-map
1272- (-lambda ((item &as &hash " name" " kind" " detail" ))
1273- (list :label (concat name (when detail
1274- (propertize (concat " - " detail) 'face 'lsp-lens-face )))
1275- :key name
1276- :icon (lsp-treemacs- -symbol-kind->icon kind)
1277- :children-async (-partial
1278- #'lsp-treemacs--call-hierarchy-children
1279- buffer
1280- (if outgoing " callHierarchy/outgoingCalls"
1281- " callHierarchy/incomingCalls" )
1282- (if outgoing " to" " from" ))
1283- :item item))
1284- (lsp-request " textDocument/prepareCallHierarchy"
1285- (lsp--text-document-position-params)))
1286- (concat (if outgoing " Outgoing" " Incoming" ) " Call Hierarchy" )
1287- nil
1288- " *Call Hierarchy*" ) nil ))))
1273+ (interactive " P" )
1274+ (unless (lsp--find-workspaces-for " textDocument/prepareCallHierarchy" )
1275+ (user-error " Call hierarchy not supported by the current servers: %s"
1276+ (-map #'lsp--workspace-print (lsp-workspaces))))
1277+ (let ((buffer (current-buffer )))
1278+ (select-window
1279+ (display-buffer-in-side-window
1280+ (lsp-treemacs-render
1281+ (seq-map
1282+ (-lambda ((item &as &hash " name" " kind" " detail" ))
1283+ (list :label (concat name (when detail
1284+ (propertize (concat " - " detail) 'face 'lsp-lens-face )))
1285+ :key name
1286+ :icon (lsp-treemacs-symbol-kind->icon kind)
1287+ :children-async (-partial
1288+ #'lsp-treemacs--call-hierarchy-children
1289+ buffer
1290+ (if outgoing " callHierarchy/outgoingCalls"
1291+ " callHierarchy/incomingCalls" )
1292+ (if outgoing " to" " from" ))
1293+ :item item))
1294+ (lsp-request " textDocument/prepareCallHierarchy"
1295+ (lsp--text-document-position-params)))
1296+ (concat (if outgoing " Outgoing" " Incoming" ) " Call Hierarchy" )
1297+ nil
1298+ " *Call Hierarchy*" ) nil ))))
12891299
12901300
12911301
0 commit comments