1 ;;; bandali-projectile.el --- bandali's Projectile setup -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2020 Amin Bandali
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: convenience
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
23 ;; My Projectile setup.
27 (use-package projectile
30 :bind-keymap
("C-c p" . projectile-command-map
)
32 (make-directory (b/var
"projectile/") t
)
35 (defun b/projectile-mode-line-fun
()
36 "Report project name and type in the modeline."
37 (let ((project-name (projectile-project-name))
38 (project-type (projectile-project-type)))
40 projectile-mode-line-prefix
42 (format ":%s" project-type
)
44 (setq projectile-mode-line-function
'b
/projectile-mode-line-fun
)
46 (defun my-projectile-invalidate-cache (&rest _args
)
47 ;; ignore the args to `magit-checkout'
48 (projectile-invalidate-cache nil
))
50 (eval-after-load 'magit-branch
52 (advice-add 'magit-checkout
53 :after
#'my-projectile-invalidate-cache
)
54 (advice-add 'magit-branch-and-checkout
55 :after
#'my-projectile-invalidate-cache
)))
57 (when (featurep 'which-key
)
58 (which-key-add-key-based-replacements
60 "C-c p s" "projectile/search"
61 "C-c p x" "projectile/execute"
62 "C-c p 4" "projectile/other-window"))
64 (projectile-cache-file (b/var
"projectile/cache.el"))
65 (projectile-completion-system 'ivy
)
66 (projectile-known-projects-file (b/var
"projectile/known-projects.el"))
67 (projectile-mode-line-prefix " proj"))
69 (provide 'bandali-projectile
)
70 ;;; bandali-projectile.el ends here