2017-08-07 06:37:47 +00:00
#+TITLE : Treemacs layer
2019-05-02 21:49:30 +00:00
#+TAGS : file tree|layer
2017-10-08 16:01:48 +00:00
[[file:img/treemacs.png ]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-08-07 06:37:47 +00:00
- [[#description ][Description ]]
- [[#features ][Features: ]]
2017-10-08 16:20:03 +00:00
- [[#install ][Install ]]
2017-08-07 06:37:47 +00:00
- [[#configuration ][Configuration ]]
2017-10-08 16:20:03 +00:00
- [[#follow-mode ][Follow mode ]]
- [[#file-watch ][File watch ]]
2019-10-04 02:47:57 +00:00
- [[#git-mode ][Git mode ]]
2017-10-08 16:20:03 +00:00
- [[#collapsed-directories ][Collapsed directories ]]
2018-10-04 10:01:49 +00:00
- [[#locking-width ][Locking width ]]
2018-12-05 03:03:03 +00:00
- [[#key-bindings ][Key bindings ]]
2017-08-07 06:37:47 +00:00
- [[#global ][Global ]]
- [[#inside-treemacs ][Inside Treemacs ]]
* Description
2019-01-19 15:25:26 +00:00
This layer sets up a file navigation and project explorer side-window via [[https://github.com/Alexander-Miller/treemacs ][Treemacs ]].
2017-10-08 16:20:03 +00:00
2017-08-07 06:37:47 +00:00
** Features:
2019-05-26 20:58:52 +00:00
An detailed overview over Treemacs' available features is available in [[https://github.com/Alexander-Miller/treemacs#detailed-feature-list][its
2017-10-08 16:20:03 +00:00
readme]]. In a short summary Treemacs offers the following:
2017-10-08 22:18:23 +00:00
- Simple and powerful navigation and ability to detail exactly how and where a
file should be opened
- Good looking png icons.
2018-11-23 12:37:48 +00:00
- Display of multiple file trees organized as projects residing in a workspace.
2017-10-08 22:18:23 +00:00
- Ability to show tags contained in files. Tags are provided by imenu, so
nearly every filetype is supported.
2018-05-25 05:39:15 +00:00
- Mouse interface for single and double left clicks in line with modern GUI standards.
2019-05-26 20:58:52 +00:00
(Clicking on an icon will also display a file's tags)
2018-05-25 05:39:15 +00:00
- Locational awareness: commands like ~find-file~ or ~magit-status~ will use the location
of the node at point (with $HOME as fallback)
2017-10-08 22:18:23 +00:00
- Optionally fontifying files based on their git status.
- Optionally collapsing single-dir-child directories into one.
- Doing both asynchronously for an imperceptible performance cost.
2019-10-05 19:47:12 +00:00
- Optional =follow-mode= to automatically focus the currently selected file or tag.
2017-10-08 22:18:23 +00:00
- Optional =filewatch-mode= to automatically refresh the view after (and only
after) changes to the shown filesystem.
2017-08-07 06:37:47 +00:00
2017-10-08 16:20:03 +00:00
* Install
To use this layer, add =treemacs= to the existing
=dotspacemacs-configuration-layers= in your =dotspacemacs= file.
* Configuration
** Follow mode
2019-10-05 19:47:12 +00:00
To have Treemacs automatically sync with your current:
- Buffer's file, set the layer variable =treemacs-use-follow-mode= to =t= .
- Tag, set the layer variable =treemacs-use-follow-mode= to =tag= .
2017-10-08 16:20:03 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
2019-10-05 19:47:12 +00:00
(treemacs :variables treemacs-use-follow-mode 'tag)))
2017-10-08 16:20:03 +00:00
#+END_SRC
2018-10-04 10:01:49 +00:00
Default is =t= .
2017-10-08 16:20:03 +00:00
** File watch
2017-10-09 06:26:04 +00:00
To automatically refresh the Treemacs buffer when there is a change in the
part of the file system shown by treemacs set the layer variable
=treemacs-use-filewatch-mode= to non-nil.
2017-10-08 16:20:03 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(treemacs :variables treemacs-use-filewatch-mode t)))
#+END_SRC
2017-08-07 06:37:47 +00:00
2018-10-04 10:01:49 +00:00
Default is =t= .
2017-08-07 06:37:47 +00:00
2019-10-04 02:47:57 +00:00
** Git mode
To enable Treemacs to check for files’ and directories’ git status information
and highlight them accordingly, set the layer variable =treemacs-use-git-mode=
to =simple= , =extended= , or =deferred= . See the [[https://github.com/Alexander-Miller/treemacs#git-mode ][Treemacs doc ]] for a more detailed
explanation.
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(treemacs :variables treemacs-use-git-mode 'deferred)))
#+END_SRC
Default is =nil= .
2017-10-08 16:20:03 +00:00
** Collapsed directories
2017-10-09 15:20:44 +00:00
*This feature requires python to be installed* .
2017-10-08 16:20:03 +00:00
Treemacs tries to collapse empty directory names into one name. It is possible
to control how deep Treemacs will search for empty directories by settings the
layer variable =treemacs-use-collapsed-directories= to a positive number.
2017-08-07 06:37:47 +00:00
#+BEGIN_SRC emacs-lisp
2017-10-08 16:20:03 +00:00
(setq-default dotspacemacs-configuration-layers '(
(treemacs :variables treemacs-use-collapsed-directories 3)))
2017-08-07 06:37:47 +00:00
#+END_SRC
2018-10-04 10:01:49 +00:00
Default is 3 (or 0 when python is not installed).
** Locking width
To have the width of the treemacs window locked by default, meaning not manually
resizable, set the variable =treemacs-lock-width= to non-nil. It will still be
2018-12-05 03:03:03 +00:00
resizable through Treemacs commands and key bindings.
2018-10-04 10:01:49 +00:00
#+BEGIN_SRC emacs-lisp
(setq-default dotspacemacs-configuration-layers '(
(treemacs :variables treemacs-lock-width t)))
#+END_SRC
Default is =nil= .
2017-08-07 06:37:47 +00:00
2018-12-05 03:03:03 +00:00
* Key bindings
2017-08-07 06:37:47 +00:00
** Global
2018-12-05 03:03:03 +00:00
| Key binding | Description |
2017-08-07 06:37:47 +00:00
|-------------+------------------------------------------------------------------------------------------------------------------------------------------------|
2018-05-19 03:41:03 +00:00
| ~M-0~ | Selected the treemacs window. Actually selects window #10, which is always assigned to treemacs. |
2017-11-26 15:00:04 +00:00
| ~SPC 0~ | Open treemacs in the current directory. When not visiting a file use $HOME as fallback. With a prefix arg manually select the root instead. |
2019-05-26 20:58:52 +00:00
| ~SPC f B~ | Find and select a bookmark. If it cannot be found rebuild view with the bookmark's location as root. Also open the bookmark with a prefix arg. |
2018-05-19 03:41:03 +00:00
| ~SPC f t~ | Hide/show existing treemacs buffer. Create one for the current directory if no buffer exists. |
| ~SPC f T~ | Manually focus the treemacs view on the currently selected file. Not needed when =treemacs-follow-mode= is enabled. |
2018-05-25 05:39:15 +00:00
| ~SPC f M-t~ | Manually focus the treemacs view on the currently selected file and tag. |
2018-09-17 02:24:00 +00:00
| ~SPC p t~ | Hide/show existing treemacs buffer. Add the current project to treemacs if not already added. |
2017-08-07 06:37:47 +00:00
** Inside Treemacs
2017-10-08 16:20:03 +00:00
Treemacs will use either ~j/k~ or ~n/p~ to go to the next/previous line,
depending on whether vim/hybrid editing style is used. Likewise refresh is only
bound to g when emacs editing style is used, since under vim g is a prefix for
many other commands.
2017-08-07 06:37:47 +00:00
2019-10-13 05:27:17 +00:00
| Key binding | Description |
|-------------+------------------------------------------------------------------------------------------------------------------|
| ~?~ | Summon the helpful hydra to show you the treemacs keymap. |
| ~M-j/M-n~ | Select next node at the same depth as currently selected node, if possible. |
| ~j/n~ | Goto next line. |
| ~k/p~ | Goto previous line. |
| ~M-J/N~ | Go to the next line in ~next-window~. |
| ~M-K/P~ | Go to the previous line in ~next-window~.. |
| ~M-j/M-n~ | Select next node at the same depth as currently selected node, if possible. |
| ~M-k/M-p~ | Select previous node at the same depth as currently selected node, if possible. |
| ~C-c C-p a~ | Select a new project to add to the treemacs workspace. |
| ~C-c C-p p~ | Select a projectile project to add to the workspace. |
| ~C-c C-p d~ | Remove project at point from the workspace. |
| ~C-c C-p r~ | Rename project at point. |
| ~th~ | Toggle the hiding and displaying of dotfiles. |
| ~tw~ | Toggle whether the treemacs buffer should have a fixed width. |
| ~tf~ | Toggle treemacs-follow-mode. |
| ~ta~ | treemacs-filewatch-mode. |
| ~w~ | Set a new value for the width of the treemacs window. |
| ~TAB~ | Do what I mean (as defined in ~treemacs-TAB-actions-config~). Prefers expanding nodes by default. |
| ~RET~ | Do what I mean (as defined in ~treemacs-RET-actions-config~). Prefers visiting nodes by default. |
| ~mouse1~ | Move point to clicked line |
| ~2x mouse1~ | Do what I mean (as defined in ~treemacs-doubleclick-actions-config~). Behaves like ~RET~ by default. |
| ~g/r/gr~ | Refresh and rebuild the treemacs buffer. |
| ~d~ | Delete node at point. A delete action must always be confirmed. Directories are deleted recursively. |
| ~cf~ | Create a file. |
| ~cd~ | Create a directory. |
| ~R~ | Rename the currently selected node. Reload buffers visiting renamed files or files in renamed directories. |
| ~u~ | Select parent of selected node, if possible. |
| ~q~ | Hide/show an existing treemacs buffer. |
| ~Q~ | Kill the treemacs buffer. |
| ~ov~ | Open current file or tag by vertically splitting ~next-window~. |
| ~oh~ | Open current file or tag by horizontally splitting ~next-window~. |
| ~oo~ | Open current file or tag, performing no split and using ~next-window~ directly. |
| ~oaa~ | Open current file or tag, using ace-window to decide which window to open the file in. |
| ~oah~ | Open current file or tag by horizontally splitting a window selected by ace-window. |
| ~oav~ | Open current file or tag by vertically splitting a window selected by ace-window. |
| ~ox~ | Open current file according to its mime type in an external application. Linux, Windows and macOS are supported. |
| ~ta~ | Toggle ~treemacs-filewatch-mode~. |
| ~tf~ | Toggle ~treemacs-follow-mode~. |
| ~th~ | Toggle the hiding and displaying of dotfiles. |
| ~tw~ | Toggle whether the treemacs buffer should have a fixed width. |
| ~yr~ | Copy the absolute path of the nearest project node at point. |
| ~yy~ | Copy the absolute path of the node at point. |