The Complete Computing Environment

Navigating Projects With Projectile


Projectile, and hydra-projectile are the tools I use to move around a project's source code. Projectile defines a wealth of Tools to enable Emacs to work with all sorts of different code projects, I can't really stress how useful this package is. My hydra uses a lot of functionality from other places, for example Deadgrep and Selectrum, etc.

(provide 'cce/projectile)
(use-package projectile
  :after (deadgrep consult)
  :hook (prog-mode . projectile-mode)
  (:map evil-leader--default-map
        ("p" . hydra-projectile/body))
  ("C-x p" . hydra-projectile/body)
  (setq projectile-switch-project-action #'projectile-commander)
  (defhydra hydra-projectile-other-window (:color teal)
    ("f"  projectile-find-file-other-window        "file")
    ("g"  projectile-find-file-dwim-other-window   "file dwim")
    ("d"  projectile-dired                         "dired")
    ("b"  projectile-switch-to-buffer-other-window "buffer")
    ("q"  nil                                      "cancel" :color blue))

  (defhydra hydra-projectile (:color teal)
     PROJECTILE: %(projectile-project-root)

Search: [_a_] deadgrep  [_A_] consult-rg
Find:   [_b_] buffer    [_d_] dir        [_f_] file
Look:   [_i_] ibuffer   [_j_] imenu

Fun:    [_o_] other win [_l_] lsp        [_K_] cleanup
    ("a"   deadgrep "rg")
    ("A"   consult-ripgrep "qrg")
    ("b"   projectile-switch-to-buffer "buf")
    ("d"   projectile-dired "dired")
    ("f"   projectile-find-file "file")
    ("i"   projectile-ibuffer "ibuf")
    ("j"   consult-imenu "imenu")
    ("K"   projectile-kill-buffers)
    ("l"   hydra-lsp/body)
    ("m"   magit-project-status)
    ("P"   projectile-switch-project)
    ("p"   projectile-switch-project)
    ("r"   projectile-recentf "recentf")
    ("x"   projectile-remove-known-project)
    ("X"   projectile-cleanup-known-projects)
    ("z"   projectile-cache-current-file)
    ("o"   hydra-projectile-other-window/body "other")
    ("q"   nil "cancel" :color blue)))