Skip to content

Commit

Permalink
[treemacs] Complete treemacs + persp-mode integration.
Browse files Browse the repository at this point in the history
 - Introduce configuration option to determine scope.
 - Activate treemacs-persp synchronization if opted in.
 - Document changes.
  • Loading branch information
Alexander-Miller authored and epsilon-0 committed Apr 21, 2020
1 parent 443e2f6 commit a2f7419
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.develop
Original file line number Diff line number Diff line change
Expand Up @@ -3248,6 +3248,9 @@ Other:
- Deleted default values to track upstream behavior
(thanks to Michael Peyton Jones)
- Removed obsolete options (thanks to Michael Peyton Jones)
- Finished =treemacs-persp= integration and made it opt-in. Using the layer
variable: =treemacs-use-scope-type= with the possible values:
='Frames= (default) or ='Perspectives= (thanks to Alexander Miller)
**** Typescript
- Call tsfmt with extension of current buffer for TSX formatting
(thanks to Victor Andrée)
Expand Down
18 changes: 18 additions & 0 deletions layers/+filetree/treemacs/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [[#configuration][Configuration]]
- [[#follow-mode][Follow mode]]
- [[#file-watch][File watch]]
- [[#scope-settings][Scope Settings]]
- [[#git-mode][Git mode]]
- [[#flattening-of-directories][Flattening of directories]]
- [[#locking-width][Locking width]]
Expand Down Expand Up @@ -73,6 +74,23 @@ part of the file system shown by treemacs set the layer variable

Default is =t=.

** Scope Settings
By default treemacs buffers and their workspaces will be uniquely scoped within
the current frame. As an alternative it is possible to scope treemacs to the
currently active perspective, including the automatic creation of a workspace
for every perspective. The scope type is determined by setting the layer
variable =treemacs-use-scope-type= to either ='Frames= or ='Perspectives=.

Note that persective-based scoping will only take effect when =persp-mode= is
actually first used.

#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(treemacs :variables treemacs-use-persp-scope 'Perspectives)))
#+END_SRC

Default is ='Frames=.

** Git mode
To enable Treemacs to check for the git status information of files and directories
and highlight them accordingly, set the layer variable =treemacs-use-git-mode=
Expand Down
6 changes: 6 additions & 0 deletions layers/+filetree/treemacs/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
(defvar treemacs-use-filewatch-mode t
"When non-nil use `treemacs-filewatch-mode'.")

(defvar treemacs-use-scope-type 'Frames
"Determines the scope of treemacs buffers and workspaces.
Possible values are:
- `Frames' - to scope treemacs to the current frame
- `Perspectives' - to scope treemacs in conjunction with `persp-mode'.")

(defvar treemacs-use-git-mode
(pcase (cons (not (null (executable-find "git")))
(not (null (executable-find "python3"))))
Expand Down
5 changes: 4 additions & 1 deletion layers/+filetree/treemacs/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@
:init (require 'treemacs-projectile)))

(defun treemacs/init-treemacs-persp ()
(use-package treemacs-persp :after treemacs))
(use-package treemacs-persp
:after treemacs persp-mode
:config (when (eq treemacs-use-scope-type 'Perspectives)
(treemacs-set-scope-type 'Perspectives))))

(defun treemacs/pre-init-winum ()
(spacemacs|use-package-add-hook winum
Expand Down

0 comments on commit a2f7419

Please sign in to comment.