From e05e452528c108e03f68dd3bad30789259b0fb1f Mon Sep 17 00:00:00 2001 From: James Ravn Date: Thu, 2 Apr 2020 21:05:49 +0100 Subject: [PATCH] Enable treemacs workspace/persp support With https://github.com/Alexander-Miller/treemacs/issues/592 merged, treemacs now fully supports perspective mode. That is, each treemacs buffer is scoped to a perspective and initializes itself using projectile. This change re-enables treemacs-persp, enables the `Perspectives` scope, and adjusts the doom treemacs init behavior to support the new treemacs-persp behavior. I haven't been able to reproduce the prior errors with melpa so I think this is safe to re-enable now. In my testing it seems to work flawlessly, both with and without persp-mode enabled. Only one issue is that users might need to remove their treemacs persist file (`~/.emacs.d/.local/cache/treemacs-persist`) after this change if using persp-mode. I'm not sure if it is necessary since I blew away my own before testing. --- modules/ui/treemacs/autoload.el | 5 +++-- modules/ui/treemacs/config.el | 5 +++++ modules/ui/treemacs/packages.el | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/ui/treemacs/autoload.el b/modules/ui/treemacs/autoload.el index 6f8b75a9c..a11fa2de6 100644 --- a/modules/ui/treemacs/autoload.el +++ b/modules/ui/treemacs/autoload.el @@ -6,8 +6,9 @@ (cl-letf (((symbol-function 'treemacs-workspace->is-empty?) (symbol-function 'ignore))) (treemacs--init)) - (dolist (project (treemacs-workspace->projects (treemacs-current-workspace))) - (treemacs-do-remove-project-from-workspace project)) + (unless (bound-and-true-p persp-mode) + (dolist (project (treemacs-workspace->projects (treemacs-current-workspace))) + (treemacs-do-remove-project-from-workspace project))) (with-current-buffer origin-buffer (let ((project-root (or (doom-project-root) default-directory))) (treemacs-do-add-project-to-workspace diff --git a/modules/ui/treemacs/config.el b/modules/ui/treemacs/config.el index 6f8a2d920..538fc6c28 100644 --- a/modules/ui/treemacs/config.el +++ b/modules/ui/treemacs/config.el @@ -66,3 +66,8 @@ This must be set before `treemacs' has loaded.") (use-package! treemacs-magit :when (featurep! :tools magit) :after treemacs magit) + +(use-package! treemacs-persp + :when (featurep! :ui workspaces) + :after (treemacs persp-mode) + :config (treemacs-set-scope-type 'Perspectives)) diff --git a/modules/ui/treemacs/packages.el b/modules/ui/treemacs/packages.el index a95c99aea..43e8c6b0d 100644 --- a/modules/ui/treemacs/packages.el +++ b/modules/ui/treemacs/packages.el @@ -7,3 +7,5 @@ (package! treemacs-projectile) (when (featurep! :tools magit) (package! treemacs-magit)) +(when (featurep! :ui workspaces) + (package! treemacs-persp))