summaryrefslogtreecommitdiffstats
path: root/lisp/init-projectile.el
blob: 75f8e6a90497097a233b36551cc2d2825bdfb959 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
;; projectile fails to load subr-x under some circumstances on 26.3
;; https://github.com/bbatsov/projectile/issues/1382

(when (< emacs-major-version 27)
  (use-package subr-x
    :ensure nil)) ;; package is bundled with emacs

(use-package projectile
  :after subr-x
  :diminish projectile-mode

  :init
  ;; use git grep
  (setq projectile-use-git-grep t)

  ;; switching project opens the top-level directory
  (setq projectile-switch-project-action 'projectile-dired)

  ;; ignore remote projects
  (setq projectile-ignored-project-function 'file-remote-p)

  ;; enable caching
  (setq projectile-enable-caching t)

  ;; avoid reading command when compiling
  (setq compilation-read-command nil)

  ;; use ivy for completion
  (setq projectile-completion-system 'ivy)

  ;; set prefix
  :bind-keymap
  ("C-c p" . projectile-command-map)

  :bind (;; C-x f finds file in project
         ("C-x f" . projectile-find-file)
         ;; C-c g runs git grep in project
         ("C-c g" . projectile-grep)
         ;; C-c m compiles project
         ;; C-u C-c m will force reading command
         ("C-c m" . projectile-compile-project))

  :config
  (projectile-mode 1))

(provide 'init-projectile)