@@ -668,6 +668,7 @@ will be rendered an empty line between them."
668668 ,@body )))
669669
670670(defvar-local lsp-treemacs-use-cache nil )
671+ (defvar-local lsp-treemacs-generic-filter nil )
671672(defvar-local lsp-treemacs--generic-cache nil )
672673
673674(defun lsp-treemacs--node-key (node )
@@ -680,31 +681,35 @@ will be rendered an empty line between them."
680681(treemacs-define-expandable-node node
681682 :icon-open-form (lsp-treemacs--generic-icon (treemacs-button-get node :item ) t )
682683 :icon-closed-form (lsp-treemacs--generic-icon (treemacs-button-get node :item ) nil )
683- :query-function (-let (((item &as &plist :children :children-async ) (treemacs-button-get node :item ))
684- (node-key (lsp-treemacs--node-key node)))
685- (cond
686- ((functionp children) (funcall children item))
687- ((and (gethash node-key lsp-treemacs--generic-cache)
688- lsp-treemacs-use-cache)
689- (cl-rest (gethash node-key lsp-treemacs--generic-cache)))
690- (children-async
691- (-let [buffer (current-buffer )]
692- (funcall children-async
693- item
694- (lambda (result )
695- (lsp-treemacs-wcb-unless-killed buffer
696- (unless (equal (gethash node-key lsp-treemacs--generic-cache)
697- (cons t result))
698- (puthash node-key (cons t result) lsp-treemacs--generic-cache)
699- (let ((lsp-treemacs-use-cache t ))
700- (treemacs-update-node (cons :custom node-key) t )))))))
701- (if-let ((cache (gethash node-key lsp-treemacs--generic-cache)))
702- (cl-rest cache)
703- `((:label ,(propertize " Loading..." 'face 'shadow )
704- :icon-literal " "
705- :key " Loading..." ))))
706- (t children)))
707- :ret-action #'lsp-treemacs-perform-ret-action
684+ :query-function
685+ (-let* (((item &as &plist :children :children-async ) (treemacs-button-get node :item ))
686+ (node-key (lsp-treemacs--node-key node))
687+ (result (cond
688+ ((functionp children) (funcall children item))
689+ ((and (gethash node-key lsp-treemacs--generic-cache)
690+ lsp-treemacs-use-cache)
691+ (cl-rest (gethash node-key lsp-treemacs--generic-cache)))
692+ (children-async
693+ (-let [buffer (current-buffer )]
694+ (funcall children-async
695+ item
696+ (lambda (result )
697+ (lsp-treemacs-wcb-unless-killed buffer
698+ (unless (equal (gethash node-key lsp-treemacs--generic-cache)
699+ (cons t result))
700+ (puthash node-key (cons t result) lsp-treemacs--generic-cache)
701+ (let ((lsp-treemacs-use-cache t ))
702+ (treemacs-update-node (cons :custom node-key) t )))))))
703+ (if-let ((cache (gethash node-key lsp-treemacs--generic-cache)))
704+ (cl-rest cache)
705+ `((:label ,(propertize " Loading..." 'face 'shadow )
706+ :icon-literal " "
707+ :key " Loading..." ))))
708+ (t children))))
709+ (if lsp-treemacs-generic-filter
710+ (funcall lsp-treemacs-generic-filter result)
711+ result))
712+ :ret-action #'lsp-treemacs-perform-ret-actionreemacs-perform-ret-action
708713 :render-action
709714 (-let [(&plist :children :label :key :children-async ) item]
710715 (treemacs-render-node
@@ -729,7 +734,6 @@ will be rendered an empty line between them."
729734
730735(defun lsp-treemacs--generic-icon (item expanded? )
731736 " Get the symbol for the the kind."
732- (message " >>> %s exp = %s " (plist-get item :label ) expanded?)
733737 (concat
734738 (if (or (plist-get item :children )
735739 (plist-get item :children-async ))
@@ -820,8 +824,8 @@ will be rendered an empty line between them."
820824 (lsp-treemacs-generic-mode t )
821825 (treemacs-GENERIC-extension)))
822826
823- (defun lsp-treemacs-generic-refresh ()
824- (let (lsp-treemacs-use-cache)
827+ (defun lsp-treemacs-generic-refresh (&optional cache )
828+ (let (( lsp-treemacs-use-cache cache) )
825829 (condition-case _err
826830 (let ((inhibit-read-only t ))
827831 (treemacs-update-node '(:custom LSP-Generic) t ))
@@ -1025,8 +1029,8 @@ With a prefix argument, show the outgoing call hierarchy."
10251029 " callHierarchy/incomingCalls" )
10261030 outgoing)
10271031 :ret-action (lambda (&rest _ )
1028- (interactive )
1029- (lsp-treemacs--call-hierarchy-ret-action item))
1032+ (interactive )
1033+ (lsp-treemacs--call-hierarchy-ret-action item))
10301034 :item item))
10311035 (lsp-request " textDocument/prepareCallHierarchy"
10321036 (lsp--text-document-position-params)))
0 commit comments