Refactor ui/treemacs

This commit is contained in:
Henrik Lissner 2018-06-10 23:16:50 +02:00 committed by GitHub
parent 24c57e785f
commit cb0ab2fcda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,45 +1,53 @@
;;; ui/treemacs/config.el -*- lexical-binding: t; -*- ;;; ui/treemacs/config.el -*- lexical-binding: t; -*-
(defvar treemacs-use-git-mode (setq treemacs-no-png-images t
(pcase (cons (not (null (executable-find "git"))) treemacs-follow-after-init t
(not (null (executable-find "python3")))) treemacs-width 35
(`(t . t) 'extended) treemacs-position 'left
(`(t . _) 'simple)) treemacs-is-never-other-window t
"Type of git integration for `treemacs-git-mode'. treemacs-silent-refresh nil
treemacs-indentation 2
treemacs-sorting 'alphabetic-desc
treemacs-show-hidden-files t
treemacs-goto-tag-strategy 'refetch-index)
(after! treemacs-persistence
(setq treemacs--persist-file (concat doom-cache-dir "treemacs-persist"))
;; Because `treemacs--persist-file' is defined with `defconst' and used
;; immediately afterwards, it cannot be easily customized before
;; `treemacs--restore' uses its value. So, we call it a second time so the
;; customization can take effect.
(unless (featurep 'treemacs)
(treemacs--restore)))
(after! treemacs
(defvar +treemacs-use-git-mode
(pcase (cons (not (null (executable-find "git")))
(not (null (executable-find "python3"))))
(`(t . t) 'extended)
(`(t . _) 'simple))
"Type of git integration for `treemacs-git-mode'.
There are 2 possible values: There are 2 possible values:
1) simple, which highlights only files based on their git status, and is 1) simple, which highlights only files based on their git status, and is
slightly faster slightly faster
2) extended, which highlights both files and directories, but requires python") 2) extended, which highlights both files and directories, but requires python")
(def-package! treemacs (defvar treemacs-collapse-dirs
:commands (treemacs treemacs-find-file treemacs-bookmark) (if (executable-find "python3") 3 0))
:config
(setq treemacs-no-png-images t
treemacs-follow-after-init t
treemacs-width 35
treemacs-position 'left
treemacs-is-never-other-window t
treemacs-silent-refresh nil
treemacs-indentation 2
treemacs-sorting 'alphabetic-desc
treemacs-show-hidden-files t
treemacs-goto-tag-strategy 'refetch-index
treemacs-collapse-dirs (if (executable-find "python3") 3 0))
(treemacs-follow-mode t) (treemacs-follow-mode t)
(treemacs-filewatch-mode t) (treemacs-filewatch-mode t)
(when (memq treemacs-use-git-mode '(simple extended)) (when (memq +treemacs-use-git-mode '(simple extended))
(treemacs-git-mode treemacs-use-git-mode))) (treemacs-git-mode +treemacs-use-git-mode)))
(add-hook! 'doom-post-init-hook
(map! :leader
:prefix "f"
:desc "Open treemacs" :nv "t" #'treemacs
:desc "Find file in treemacs" :nv "T" #'treemacs-find-file
:desc "Go to bookmark" :nv "b" #'treemacs-bookmark))
(def-package! treemacs-evil (def-package! treemacs-evil
:after (treemacs evil) :when (featurep! :feature evil +everywhere)
:if (featurep! :feature evil)) :after treemacs)
(def-package! treemacs-projectile (def-package! treemacs-projectile
:after (treemacs projectile)) :after treemacs)