/
init-project.el
104 lines (96 loc) · 3.76 KB
/
init-project.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
;;; -*- lexical-binding: t -*-
;;; 项目管理
(use-package project
:bind
("C-x p" . hydra-project/body)
:config
(defhydra hydra-project (:color blue
:hint nil
:columns 5)
"Project Commands"
("b" project-list-buffers "List Buffers" :color blue)
("x" project-execute-extended-command "Execute Extended Command" :color blue)
("r" project-query-replace-regexp "Query Replace Regexp" :color blue)
("G" project-or-external-find-regexp "Find Regexp (External)" :color blue)
("g" project-find-regexp "Find Regexp (Project)" :color blue)
("p" project-switch-project "Switch Project" :color blue)
("k" project-kill-buffers "Kill Buffers" :color blue)
("e" project-eshell "Eshell" :color blue)
("c" project-compile "Compile" :color blue)
("v" project-vc-dir "Version Control (VC) Dir" :color blue)
("D" project-dired "Dired" :color blue)
("d" project-find-dir "Find Directory" :color blue)
("s" project-shell "Shell" :color blue)
("S" project-switch-to-buffer "Switch to Buffer" :color blue)
("F" project-or-external-find-file "Find File (External)" :color blue)
("f" project-find-file "Find File" :color blue)
("&" project-async-shell-command "Async Shell Command" :color blue)
("!" project-shell-command "Shell Command" :color blue))
;; don't consider the submodules is a part of the parent, which is convenient in search
(setq project-vc-merge-submodules nil)
)
(use-package treemacs
:straight t
:functions
(treemacs-filewatch-mode treemacs-git-mode treemacs-delete-other-windows)
:custom-face
(cfrs-border-color ((t (:inherit posframe-border))))
(variable-pitch ((t nil))) ; 取消 treemacs 的默认字体
:bind
(("M-0" . +switch-with-treemacs)
("<f6>" . +treemacs-toggle)
:map treemacs-mode-map
([mouse-1] . treemacs-single-click-expand-action))
:config
;; Bind after load treemacs
;; (bind-keys :package treemacs
;; ("C-x 1" . treemacs-delete-other-windows))
;; treemacs-git-mode
(pcase (cons (not (null (executable-find "git")))
(not (null (executable-find "python3"))))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple)))
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-missing-project-action 'remove
treemacs-sorting 'alphabetic-case-insensitive-asc
treemacs-follow-after-init t
treemacs-is-never-other-window t
treemacs-width 30
treemacs-no-png-images nil)
(treemacs-filewatch-mode t)
(treemacs-follow-mode -1)
(defun +treemacs-toggle ()
(interactive)
(require 'treemacs)
(pcase (treemacs-current-visibility)
(`visible (delete-window (treemacs-get-local-window)))
(_ (if (project-current)
(treemacs-add-and-display-current-project-exclusively)
(treemacs)))))
(defun +switch-with-treemacs()
(interactive)
(require 'treemacs)
(if (not (eq (treemacs-current-visibility) `visible))
(+treemacs-toggle)
(if (eq (treemacs-get-local-window) (get-buffer-window))
(other-window -1)
(select-window (treemacs-get-local-window))
)
)
)
(custom-set-faces
'(variable-pitch ((t nil))) ; 严格意义上说,取消 treemacs 的默认字体
'(variable-pitch ((t (:height 0.9)))) ; 缩小默认字体
)
)
;; (use-package treemacs-magit
;; :straight t
;; :demand t
;; :after treemacs magit
;; :commands treemacs-magit--schedule-update
;; :hook ((magit-post-commit
;; git-commit-post-finish
;; magit-post-stage
;; magit-post-unstage) . treemacs-magit--schedule-update))