From dc52243185ceea779466d90070d0ad98a4976250 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Tue, 18 Nov 2025 13:45:03 +0100 Subject: [PATCH] Show errors on the project in lsp-treemacs-error-list At least JDTLS also reports errors directly on the project (rather than just files and folders under the project). These were previously not shown at all in the lsp-treemacs error list, leading to weird cases where there was an entry with an error count but no children. This changes it so the errors on the project are shown directly. --- lsp-treemacs.el | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/lsp-treemacs.el b/lsp-treemacs.el index 6413fcd..6d97841 100644 --- a/lsp-treemacs.el +++ b/lsp-treemacs.el @@ -961,27 +961,30 @@ With prefix 2 show both." (ht-keys) (-keep (lambda (file) - (when (and (lsp-f-ancestor-of? folder file) - (lsp-treemacs-errors--diags? (lsp-diagnostics-stats-for file))) - (list :id file - :label (format "%s %s %s" - (f-filename file) - (->> (append (lsp-diagnostics-stats-for file) ()) - (-map-indexed - (lambda (index count) - (unless (zerop count) - (propertize - (number-to-string count) - 'face (alist-get index lsp-treemacs-file-face-map))))) - (-filter #'identity) - (s-join "/")) - (propertize (f-dirname (f-relative file folder)) - 'face 'lsp-details-face)) - :icon (if (f-directory? file) 'dir-closed (f-ext file)) - :children (-partial #'lsp-treemacs--error-list-diags folder file) - :ret-action (lambda (&rest _) - (interactive) - (lsp-treemacs--open-file-in-mru file)))))))) + (if (and (lsp-f-ancestor-of? folder file) + (lsp-treemacs-errors--diags? (lsp-diagnostics-stats-for file))) + (list (list :id file + :label (format "%s %s %s" + (f-filename file) + (->> (append (lsp-diagnostics-stats-for file) ()) + (-map-indexed + (lambda (index count) + (unless (zerop count) + (propertize + (number-to-string count) + 'face (alist-get index lsp-treemacs-file-face-map))))) + (-filter #'identity) + (s-join "/")) + (propertize (f-dirname (f-relative file folder)) + 'face 'lsp-details-face)) + :icon (if (f-directory? file) 'dir-closed (f-ext file)) + :children (-partial #'lsp-treemacs--error-list-diags folder file) + :ret-action (lambda (&rest _) + (interactive) + (lsp-treemacs--open-file-in-mru file)))) + (if (lsp-f-same? folder file) + (lsp-treemacs--error-list-diags folder file))))) + (-flatten-n 1))) (lsp-treemacs-define-action lsp-treemacs-quick-fix (:file :diag) "Select the element under cursor."