Drop no-littering
[~bandali/configs] / lisp / bandali-projectile.el
CommitLineData
1eb20313
AB
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
0596e3cf 32 (make-directory (b/var "projectile/") t)
1eb20313
AB
33 (projectile-mode)
34
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)))
39 (format "%s%s"
40 projectile-mode-line-prefix
41 (if project-type
42 (format ":%s" project-type)
43 ""))))
44 (setq projectile-mode-line-function 'b/projectile-mode-line-fun)
45
46 (defun my-projectile-invalidate-cache (&rest _args)
47 ;; ignore the args to `magit-checkout'
48 (projectile-invalidate-cache nil))
49
50 (eval-after-load 'magit-branch
51 '(progn
52 (advice-add 'magit-checkout
53 :after #'my-projectile-invalidate-cache)
54 (advice-add 'magit-branch-and-checkout
55 :after #'my-projectile-invalidate-cache)))
56
57 (when (featurep 'which-key)
58 (which-key-add-key-based-replacements
59 "C-c p" "projectile"
60 "C-c p s" "projectile/search"
61 "C-c p x" "projectile/execute"
62 "C-c p 4" "projectile/other-window"))
63 :custom
0596e3cf 64 (projectile-cache-file (b/var "projectile/cache.el"))
1eb20313 65 (projectile-completion-system 'ivy)
0596e3cf 66 (projectile-known-projects-file (b/var "projectile/known-projects.el"))
1eb20313
AB
67 (projectile-mode-line-prefix " proj"))
68
69(provide 'bandali-projectile)
70;;; bandali-projectile.el ends here