-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-projects.el
50 lines (46 loc) · 1.93 KB
/
init-projects.el
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
47
48
49
50
(use-package projectile
:custom (projectile-current-project-on-switch 'move-to-end)
:demand t
:config
(projectile-mode 1)
(jester/with-leader
"p K" 'projectile-kill-buffers
"p s" 'jester/select-project-and-search
"p g" 'jester/select-project-and-magit-status
"p p" 'jester/select-project-and-open-file)
(defvar jester-projectile-project-history nil "projectile project history")
(defun jester/select-project-and-do (action &optional do-what)
"Select a project with projectile, then do `ACTION' in the project.
`ACTION' takes one arg, the selected project dir.
`DO-WHAT' is a string, which is action name displayed by completion interface."
(let ((projects (projectile-relevant-known-projects)))
(if projects
(ivy-read (concat (when do-what (format "%s " do-what)) "in project: ")
projects
:history 'jester-projectile-project-history
:action action)
(user-error "There are no known projects"))))
(defun jester/select-project-and-search ()
"Select a project with projectile, and search it."
(interactive)
(jester/select-project-and-do
(lambda (project-dir) (let ((default-directory project-dir))
(counsel-rg)))
"search"))
(defun jester/select-project-and-magit-status ()
"Select a project with projectile, and open magit status."
(interactive)
(jester/select-project-and-do
(lambda (project-dir) (let ((default-directory project-dir))
(magit-status)))
"magit"))
;; TODO pre select the same file name as current buffer
(defun jester/select-project-and-open-file ()
"Select a project with projectile, and open a file."
(interactive)
(jester/select-project-and-do
(lambda (project-dir) (let ((default-directory project-dir))
(counsel-git)))
"open file")))
(use-package find-file-in-project)
(provide 'init-projects)