forked from syl20bnr/spacemacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackages.el
376 lines (343 loc) · 11.8 KB
/
packages.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
;;; packages.el --- Git Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <[email protected]>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defvar git-packages
'(
gitattributes-mode
gitconfig-mode
gitignore-mode
git-commit-mode
git-messenger
git-rebase-mode
git-timemachine
gist
github-browse-file
git-link
;; not up to date
;; helm-gist
magit
magit-gh-pulls
magit-gitflow
magit-svn
smeargle
)
"List of all packages to install and/or initialize. Built-in packages
which require an initialization must be listed explicitly in the list.")
(if git-gutter-use-fringe
(push 'git-gutter-fringe git-packages)
(push 'git-gutter git-packages))
(defun git/init-gist ()
(use-package gist
:if git-enable-github-support
:defer t
:init
(progn
(evilify gist-list-menu-mode gist-list-menu-mode-map
"f" 'gist-fetch-current
"K" 'gist-kill-current
"o" 'gist-browse-current-url)
(evil-leader/set-key
"ggb" 'gist-buffer
"ggB" 'gist-buffer-private
"ggl" 'gist-list
"ggr" 'gist-region
"ggR" 'gist-region-private))))
(defun git/init-git-commit-mode ()
(use-package git-commit-mode
:defer t
:config
(evil-leader/set-key-for-mode 'git-commit-mode
"mcc" 'git-commit-commit
"mk" 'git-commit-abort)))
(defun init-git-gutter ()
"Common initialization of git-gutter."
(git-gutter-mode)
(setq git-gutter:modified-sign " ")
(setq git-gutter:added-sign "+")
(setq git-gutter:deleted-sign "-")
(spacemacs|hide-lighter git-gutter-mode)
(if (and (not git-gutter-use-fringe)
global-linum-mode)
(git-gutter:linum-setup)))
(defun git/init-git-gutter ()
(use-package git-gutter
:commands git-gutter-mode
:init
(progn
(init-git-gutter)
(add-to-hooks 'git-gutter-mode '(markdown-mode-hook
org-mode-hook
prog-mode-hook)))))
(defun git/init-git-gutter-fringe ()
(use-package git-gutter-fringe
:commands git-gutter-mode
:init
(progn
(defun git/load-git-gutter ()
"Lazy load git gutter and choose between fringe and no fringe."
(when (display-graphic-p) (require 'git-gutter-fringe))
(init-git-gutter))
(setq git-gutter-fr:side 'right-fringe)
(add-to-hooks 'git/load-git-gutter '(markdown-mode-hook
org-mode-hook
prog-mode-hook)))
:config
(progn
(setq git-gutter:hide-gutter t)
;; Don't need log/message.
(setq git-gutter:verbosity 0)
(evil-leader/set-key
"ghs" 'git-gutter:stage-hunk
"ghr" 'git-gutter:revert-hunk
"ghN" 'git-gutter:previous-hunk
"ghn" 'git-gutter:next-hunk)
;; (setq git-gutter:update-hooks '(after-save-hook after-revert-hook))
;; custom graphics that works nice with half-width fringes
(fringe-helper-define 'git-gutter-fr:added nil
"..X...."
"..X...."
"XXXXX.."
"..X...."
"..X...."
)
(fringe-helper-define 'git-gutter-fr:deleted nil
"......."
"......."
"XXXXX.."
"......."
"......."
)
(fringe-helper-define 'git-gutter-fr:modified nil
"..X...."
".XXX..."
"XXXXX.."
".XXX..."
"..X...."
))))
(defun git/init-git-messenger ()
(use-package git-messenger
:defer t
:init
(evil-leader/set-key
"gm" 'git-messenger:popup-message)))
(defun git/init-git-rebase-mode ()
(use-package git-rebase-mode
:defer t
:config
(progn
(evilify git-rebase-mode git-rebase-mode-map
"J" 'git-rebase-move-line-down
"K" 'git-rebase-move-line-up
"u" 'git-rebase-undo
"y" 'git-rebase-insert)
(evil-leader/set-key-for-mode 'git-rebase-mode
"mcc" 'git-rebase-server-edit
"mk" 'git-rebase-abort))))
(defun git/init-git-timemachine ()
(use-package git-timemachine
:defer t
:commands spacemacs/time-machine-micro-state
:init
(evil-leader/set-key
"gt" 'spacemacs/time-machine-micro-state)
:config
(progn
(defun spacemacs//time-machine-ms-on-enter ()
"Initiate git-timemachine properly with goden-ratio support."
(let ((golden-ratio (when (boundp 'golden-ratio-mode)
golden-ratio-mode)))
(when (bound-and-true-p golden-ratio-mode) (golden-ratio-mode -1))
(git-timemachine)
(when golden-ratio (golden-ratio-mode))))
(spacemacs|define-micro-state time-machine
:doc "[p] [N] previous [n] next [c] current [Y] copy hash [q] quit"
:on-enter (spacemacs//time-machine-ms-on-enter)
:on-exit (git-timemachine-quit)
:persistent t
:bindings
("c" git-timemachine-show-current-revision)
("p" git-timemachine-show-previous-revision)
("n" git-timemachine-show-next-revision)
("N" git-timemachine-show-previous-revision)
("Y" git-timemachine-kill-revision)
("q" nil :exit t)))))
(defun git/init-gitattributes-mode ()
(use-package gitattributes-mode
:defer t))
(defun git/init-gitconfig-mode ()
(use-package gitconfig-mode
:defer t))
(defun git/init-gitignore-mode ()
(use-package gitignore-mode
:defer t))
;; this mode is not up to date
;; any contributor to make it up to date is welcome:
;; https://github.com/emacs-helm/helm-gist
;;
;; (defun git/init-helm-gist ()
;; (use-package helm-gist
;; :commands egist-mode
;; :init
;; (progn
;; (defun spacemacs/helm-gist-list ()
;; "List the gists using helm, ensure thath elgist-mode is enabled."
;; (interactive)
;; (egist-mode)
;; (helm-for-gist))
;; (evil-leader/set-key "ggh" 'spacemacs/helm-gist-list))
;; ))
(defun git/init-magit ()
(use-package magit
:defer t
:init
(progn
(setq magit-last-seen-setup-instructions "1.4.0"
magit-completing-read-function 'magit-ido-completing-read)
;; On Windows, we must use Git GUI to enter username and password
;; See: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https
(when (eq window-system 'w32)
(setenv "GIT_ASKPASS" "git-gui--askpass"))
(evil-leader/set-key
"gb" 'magit-blame-mode
"gl" 'magit-log
"gs" 'magit-status
"gC" 'magit-commit)
(evilify magit-commit-mode magit-commit-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-log-mode magit-log-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-process-mode magit-process-mode-map
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-branch-manager-mode magit-branch-manager-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item)
(evilify magit-status-mode magit-status-mode-map
"K" 'magit-discard-item
"L" 'magit-key-mode-popup-logging
"H" 'magit-key-mode-popup-diff-options
(kbd "C-j") 'magit-goto-next-section
(kbd "C-k") 'magit-goto-previous-section
(kbd "C-n") 'magit-goto-next-section
(kbd "C-p") 'magit-goto-previous-section
(kbd "C-v") 'magit-revert-item))
:config
(progn
(spacemacs|hide-lighter magit-auto-revert-mode)
;; full screen magit-status
(when git-magit-status-fullscreen
(defadvice magit-status (around magit-fullscreen activate)
(window-configuration-to-register :magit-fullscreen)
ad-do-it
(delete-other-windows))
(defun magit-quit-session ()
"Restores the previous window configuration and kills the magit buffer"
(interactive)
(kill-buffer)
(jump-to-register :magit-fullscreen))
(define-key magit-status-mode-map (kbd "q") 'magit-quit-session))
(defun magit-toggle-whitespace ()
(interactive)
(if (member "-w" magit-diff-options)
(magit-dont-ignore-whitespace)
(magit-ignore-whitespace)))
(defun magit-ignore-whitespace ()
(interactive)
(add-to-list 'magit-diff-options "-w")
(magit-refresh))
(defun magit-dont-ignore-whitespace ()
(interactive)
(setq magit-diff-options (remove "-w" magit-diff-options))
(magit-refresh))
(define-key magit-status-mode-map (kbd "W") 'magit-toggle-whitespace))))
(defun git/init-magit-gh-pulls ()
(use-package magit-gh-pulls
:if git-enable-github-support
:defer t
:init
(progn
(defun spacemacs/load-gh-pulls-mode ()
"Start `magit-gh-pulls-mode' only after a manual request."
(interactive)
(magit-gh-pulls-mode)
(magit-gh-pulls-reload))
(eval-after-load 'magit
'(define-key magit-mode-map "#gg" 'spacemacs/load-gh-pulls-mode)))
:config
(spacemacs|diminish magit-gh-pulls-mode "Github-PR")))
(defun git/init-github-browse-file ()
(use-package github-browse-file
:if git-enable-github-support
:defer t
:init
(evil-leader/set-key
"gfb" 'github-browse-file)))
(defun git/init-git-link ()
(use-package git-link
:if git-enable-github-support
:defer t
:init
(progn
(defun spacemacs/git-link-copy-url-only ()
"Only copy the generated link to the kill ring."
(interactive)
(let (git-link-open-in-browser)
(call-interactively 'git-link)))
(defun spacemacs/git-link-commit-copy-url-only ()
"Only copy the generated link to the kill ring."
(interactive)
(let (git-link-open-in-browser)
(call-interactively 'git-link-commit)))
(evil-leader/set-key
"gfl" 'git-link
"gfL" 'spacemacs/git-link-copy-url-only
"gfc" 'git-link-commit
"gfC" 'spacemacs/git-link-commit-copy-url-only)
;; default is to open the generated link
(setq git-link-open-in-browser t))))
(defun git/init-magit-gitflow ()
(use-package magit-gitflow
:commands turn-on-magit-gitflow
:init (add-hook 'magit-mode-hook 'turn-on-magit-gitflow)
:config (spacemacs|diminish magit-gitflow-mode "Flow")))
(defun git/init-magit-svn ()
(use-package magit-svn
:if git-enable-magit-svn-plugin
:commands turn-on-magit-svn
:init (add-hook 'magit-mode-hook 'turn-on-magit-svn)
:config
(progn
(evil-define-key 'emacs magit-status-mode-map
"N" 'magit-key-mode-popup-svn))))
(defun git/init-smeargle ()
(use-package smeargle
:defer t
:init
(evil-leader/set-key
"ghc" 'smeargle-clear
"ghh" 'smeargle-commits
"ght" 'smeargle)))