2018-06-15 03:10:55 +02:00
|
|
|
;;; ui/treemacs/autoload.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun +treemacs/toggle ()
|
|
|
|
"Initialize or toggle treemacs.
|
|
|
|
* If the treemacs window is visible hide it.
|
|
|
|
* If a treemacs buffer exists, but is not visible show it.
|
|
|
|
* If no treemacs buffer exists for the current frame create and show it.
|
|
|
|
* If the workspace is empty additionally ask for the root path of the first
|
|
|
|
project to add."
|
|
|
|
(interactive)
|
|
|
|
(require 'treemacs)
|
2018-08-04 12:18:54 +02:00
|
|
|
(pcase (treemacs-current-visibility)
|
2018-08-06 11:18:26 +02:00
|
|
|
(`visible (delete-window (treemacs-get-local-window)))
|
2018-07-01 01:16:37 +02:00
|
|
|
(`exists (treemacs-select-window))
|
|
|
|
(`none
|
2018-06-15 03:10:55 +02:00
|
|
|
(let ((project-root (doom-project-root 'nocache)))
|
|
|
|
(when project-root
|
|
|
|
(unless (treemacs--find-project-for-path project-root)
|
|
|
|
(treemacs-add-project-at (treemacs--canonical-path project-root)
|
|
|
|
(doom-project-name 'nocache))))
|
2018-07-01 01:16:37 +02:00
|
|
|
(treemacs--init project-root)))))
|