From 7175c7dffb137cf1169fccabb10906936f79e052 Mon Sep 17 00:00:00 2001 From: Aria Edmonds Date: Sat, 9 Jun 2018 12:16:29 +1000 Subject: [PATCH 1/7] Add initial treemacs module --- modules/ui/treemacs/config.el | 45 +++++++++++++++++++++++++++++++++ modules/ui/treemacs/packages.el | 7 +++++ 2 files changed, 52 insertions(+) create mode 100644 modules/ui/treemacs/config.el create mode 100644 modules/ui/treemacs/packages.el diff --git a/modules/ui/treemacs/config.el b/modules/ui/treemacs/config.el new file mode 100644 index 000000000..15fdd19f6 --- /dev/null +++ b/modules/ui/treemacs/config.el @@ -0,0 +1,45 @@ +;;; ui/treemacs/config.el -*- lexical-binding: t; -*- + +(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: +1) simple, which highlights only files based on their git status, and is + slightly faster +2) extended, which highlights both files and directories, but requires python") + +(def-package! treemacs + :commands (treemacs treemacs-find-file treemacs-bookmark) + :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-filewatch-mode t) + (when (memq treemacs-use-git-mode '(simple extended)) + (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 + :after (treemacs evil) + :if (featurep! :feature evil)) + +(def-package! treemacs-projectile + :after (treemacs projectile)) diff --git a/modules/ui/treemacs/packages.el b/modules/ui/treemacs/packages.el new file mode 100644 index 000000000..7125f777a --- /dev/null +++ b/modules/ui/treemacs/packages.el @@ -0,0 +1,7 @@ +;; -*- no-byte-compile: t; -*- +;;; ui/treemacs/packages.el + +(package! treemacs) +(when (featurep! :feature evil) + (package! treemacs-evil)) +(package! treemacs-projectile) From 8dbebf658811097d16147e40bd1862da4d6e1797 Mon Sep 17 00:00:00 2001 From: Aria Edmonds Date: Sat, 9 Jun 2018 12:16:53 +1000 Subject: [PATCH 2/7] Add treemacs to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9e9f3ed2c..96aba118a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ network-security.data # transient files *.cache-* *.log +/.cache/treemacs-persist From 981116d5091224f5a786bc2dea0b3ee6eb9fa01c Mon Sep 17 00:00:00 2001 From: Aria Edmonds Date: Sat, 9 Jun 2018 12:18:16 +1000 Subject: [PATCH 3/7] Add treemacs to init.example.el --- init.example.el | 1 + 1 file changed, 1 insertion(+) diff --git a/init.example.el b/init.example.el index 7d03efd15..78c9c05b4 100644 --- a/init.example.el +++ b/init.example.el @@ -34,6 +34,7 @@ hl-todo ; highlight TODO/FIXME/NOTE tags nav-flash ; blink the current line after jumping neotree ; a project drawer, like NERDTree for vim + treemacs ; a project drawer, like neotree but cooler (popup ; tame sudden yet inevitable temporary windows +all ; catch all popups that start with an asterix +defaults) ; default popup rules From 24c57e785f9fc10432fb197f0f5414c3bfe82ed7 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 Jun 2018 23:15:58 +0200 Subject: [PATCH 4/7] Disable both treemacs by default Once treemacs has been through its rounds (and I've customed its icons), it will likely become the new default, but for now, neotree still wins. --- init.example.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.example.el b/init.example.el index 78c9c05b4..f3996ae58 100644 --- a/init.example.el +++ b/init.example.el @@ -34,7 +34,7 @@ hl-todo ; highlight TODO/FIXME/NOTE tags nav-flash ; blink the current line after jumping neotree ; a project drawer, like NERDTree for vim - treemacs ; a project drawer, like neotree but cooler + ;treemacs ; a project drawer, like neotree but cooler (popup ; tame sudden yet inevitable temporary windows +all ; catch all popups that start with an asterix +defaults) ; default popup rules From cb0ab2fcda3f8519407f87168c458587a354d3e5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 Jun 2018 23:16:50 +0200 Subject: [PATCH 5/7] Refactor ui/treemacs --- modules/ui/treemacs/config.el | 70 +++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/modules/ui/treemacs/config.el b/modules/ui/treemacs/config.el index 15fdd19f6..5b7074763 100644 --- a/modules/ui/treemacs/config.el +++ b/modules/ui/treemacs/config.el @@ -1,45 +1,53 @@ ;;; ui/treemacs/config.el -*- lexical-binding: t; -*- -(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'. +(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) + + +(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: 1) simple, which highlights only files based on their git status, and is slightly faster 2) extended, which highlights both files and directories, but requires python") -(def-package! treemacs - :commands (treemacs treemacs-find-file treemacs-bookmark) - :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)) + (defvar treemacs-collapse-dirs + (if (executable-find "python3") 3 0)) + (treemacs-follow-mode t) (treemacs-filewatch-mode t) - (when (memq treemacs-use-git-mode '(simple extended)) - (treemacs-git-mode treemacs-use-git-mode))) + (when (memq +treemacs-use-git-mode '(simple extended)) + (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 - :after (treemacs evil) - :if (featurep! :feature evil)) + :when (featurep! :feature evil +everywhere) + :after treemacs) + (def-package! treemacs-projectile - :after (treemacs projectile)) + :after treemacs) From cf6b4f891e82660d69f0128d3a5e938a4006b1e1 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 Jun 2018 23:17:12 +0200 Subject: [PATCH 6/7] Add +everywhere flag to treemacs-evil --- modules/ui/treemacs/packages.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/treemacs/packages.el b/modules/ui/treemacs/packages.el index 7125f777a..8d203580f 100644 --- a/modules/ui/treemacs/packages.el +++ b/modules/ui/treemacs/packages.el @@ -2,6 +2,6 @@ ;;; ui/treemacs/packages.el (package! treemacs) -(when (featurep! :feature evil) +(when (featurep! :feature evil +everywhere) (package! treemacs-evil)) (package! treemacs-projectile) From 7ebedf90ab610e56a9e0655e73743db0293f9061 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 10 Jun 2018 23:18:27 +0200 Subject: [PATCH 7/7] Remove .gitignore entry treemacs--persist-file has been changed --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 96aba118a..9e9f3ed2c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,3 @@ network-security.data # transient files *.cache-* *.log -/.cache/treemacs-persist