Created
August 26, 2020 15:58
-
-
Save erickgnavar/593c572553c77fae1237f6e77d145130 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(tab-bar-mode 1) | |
(defvar my/projects-tabs-map ()) | |
(defun my/projectile-switch-action () | |
"Create a new tab when a new project is opened, it saves the tab index into `my/projects-tabs-map' | |
using the project name as its key." | |
(tab-bar-new-tab) | |
(setf (alist-get (projectile-project-name) my/projects-tabs-map) (tab-bar--current-tab-index)) | |
(helm-ls-git-ls)) | |
(defun my/projectile-kill-buffers () | |
"Delete the current tab when all project related buffers are killed." | |
(interactive) | |
(let* ((project-name (projectile-project-name)) | |
(tab-index (cdr (assoc (projectile-project-name) my/projects-tabs-map)))) | |
(projectile-kill-buffers) | |
;; we delete the tab only when the user accept to kill all the project related buffers, | |
;; `projectile-kill-buffers' doesn't return a value so to make this validation we compare | |
;; the current project-name against the value of `project-name' that was computed before | |
(unless (string-equal (projectile-project-name) project-name) | |
(setf my/projects-tabs-map (assoc-delete-all project-name my/projects-tabs-map)) | |
(tab-bar-close-tab tab-index)))) | |
(use-package projectile | |
:ensure t | |
:delight '(:eval (format "Proj[%s]" (projectile-project-name))) | |
:custom | |
(projectile-keymap-prefix (kbd "C-c p")) | |
(projectile-switch-project-action 'my/projectile-switch-action) | |
(projectile-completion-system 'helm) | |
:bind (:map projectile-mode-map | |
("C-c p k" . 'my/projectile-kill-buffers)) | |
:hook | |
(after-init . projectile-mode)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment