CHANGE 9 drones
[~bandali/configs] / lisp / bandali-projectile.el
1 ;;; bandali-projectile.el --- bandali's Projectile setup -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2020 Amin Bandali
4
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: convenience
7
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.
12
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.
17
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/>.
20
21 ;;; Commentary:
22
23 ;; My Projectile setup.
24
25 ;;; Code:
26
27 (use-package projectile
28 :disabled
29 :defer 0.5
30 :bind-keymap ("C-c p" . projectile-command-map)
31 :config
32 (projectile-mode)
33
34 (defun b/projectile-mode-line-fun ()
35 "Report project name and type in the modeline."
36 (let ((project-name (projectile-project-name))
37 (project-type (projectile-project-type)))
38 (format "%s%s"
39 projectile-mode-line-prefix
40 (if project-type
41 (format ":%s" project-type)
42 ""))))
43 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
44
45 (defun my-projectile-invalidate-cache (&rest _args)
46 ;; ignore the args to `magit-checkout'
47 (projectile-invalidate-cache nil))
48
49 (eval-after-load 'magit-branch
50 '(progn
51 (advice-add 'magit-checkout
52 :after #'my-projectile-invalidate-cache)
53 (advice-add 'magit-branch-and-checkout
54 :after #'my-projectile-invalidate-cache)))
55
56 (when (featurep 'which-key)
57 (which-key-add-key-based-replacements
58 "C-c p" "projectile"
59 "C-c p s" "projectile/search"
60 "C-c p x" "projectile/execute"
61 "C-c p 4" "projectile/other-window"))
62 :custom
63 (projectile-completion-system 'ivy)
64 (projectile-mode-line-prefix " proj"))
65
66 (provide 'bandali-projectile)
67 ;;; bandali-projectile.el ends here