treemacs: create and bind toggle project function

This commit is contained in:
Kalle Lindqvist 2018-08-31 23:28:12 +02:00 committed by Codruț Constantin Gușoi
parent 89caca3048
commit ba93316939
2 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,22 @@
;;; packages.el --- Neotree Layer functions File
;;
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defun spacemacs/treemacs-project-toggle ()
"Toggle and add the current project to treemacs if not already added."
(interactive)
(if (eq (treemacs-current-visibility) 'visible)
(delete-window (treemacs-get-local-window))
(let ((path (projectile-project-root))
(name (projectile-project-name)))
(unless (treemacs-current-workspace)
(treemacs--find-workspace))
(treemacs-do-add-project-to-workspace path name)
(treemacs-select-window))))

View File

@ -24,7 +24,8 @@
(defun treemacs/init-treemacs ()
(use-package treemacs
:commands (treemacs-select-window treemacs--window-number-ten)
:commands (treemacs-select-window treemacs--window-number-ten
treemacs-current-visibility)
:defer t
:init
(progn
@ -44,7 +45,8 @@
"ft" 'treemacs
"fB" 'treemacs-bookmark
"fT" 'treemacs-find-file
"f M-t" 'treemacs-find-tag)
"f M-t" 'treemacs-find-tag
"pt" 'spacemacs/treemacs-project-toggle)
(which-key-add-major-mode-key-based-replacements 'treemacs-mode
"c" "treemacs-create"
"o" "treemacs-visit-node"