2015-01-14 04:12:56 +00:00
|
|
|
;;; packages.el --- Git Layer packages File for Spacemacs
|
|
|
|
;;
|
|
|
|
;; Copyright (c) 2012-2014 Sylvain Benner
|
|
|
|
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
|
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
2015-04-19 03:40:24 +00:00
|
|
|
(setq git-packages
|
2015-06-09 15:43:14 +00:00
|
|
|
'(
|
2015-11-06 23:24:51 +00:00
|
|
|
evil-magit
|
2015-06-09 15:43:14 +00:00
|
|
|
gitattributes-mode
|
|
|
|
gitconfig-mode
|
|
|
|
gitignore-mode
|
2015-07-09 22:52:18 +00:00
|
|
|
git-commit
|
2015-06-09 15:43:14 +00:00
|
|
|
git-messenger
|
|
|
|
git-timemachine
|
|
|
|
helm-gitignore
|
2015-07-02 04:36:26 +00:00
|
|
|
magit
|
2015-07-25 14:44:18 +00:00
|
|
|
magit-gitflow
|
2015-07-02 04:36:26 +00:00
|
|
|
;; not compatible with magit 2.1 at the time of release
|
|
|
|
;; magit-svn
|
|
|
|
smeargle
|
|
|
|
))
|
2015-06-24 03:52:24 +00:00
|
|
|
|
2015-10-28 13:13:11 +00:00
|
|
|
(defun git/init-evil-magit ()
|
2015-10-29 16:21:17 +00:00
|
|
|
(unless (eq dotspacemacs-editing-style 'emacs)
|
|
|
|
(with-eval-after-load 'magit
|
2015-11-19 13:53:10 +00:00
|
|
|
(require 'evil-magit)
|
|
|
|
(evil-define-key 'motion magit-mode-map
|
|
|
|
(kbd dotspacemacs-leader-key) spacemacs-default-map))))
|
2015-10-28 13:13:11 +00:00
|
|
|
|
2015-05-18 02:43:42 +00:00
|
|
|
(defun git/init-helm-gitignore ()
|
|
|
|
(use-package helm-gitignore
|
|
|
|
:defer t
|
2015-11-18 00:38:05 +00:00
|
|
|
:init (spacemacs/set-leader-keys "gI" 'helm-gitignore)))
|
2015-05-18 02:43:42 +00:00
|
|
|
|
2015-07-09 22:52:18 +00:00
|
|
|
(defun git/init-git-commit ()
|
2015-07-26 05:03:30 +00:00
|
|
|
(use-package git-commit
|
|
|
|
:defer t))
|
2015-07-09 22:52:18 +00:00
|
|
|
|
2014-12-14 04:59:02 +00:00
|
|
|
(defun git/init-git-messenger ()
|
|
|
|
(use-package git-messenger
|
|
|
|
:defer t
|
|
|
|
:init
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2015-07-25 11:47:20 +00:00
|
|
|
"gm" 'git-messenger:popup-message)
|
|
|
|
:config
|
|
|
|
(define-key git-messenger-map [escape] 'git-messenger:popup-close)
|
|
|
|
))
|
2014-12-14 04:59:02 +00:00
|
|
|
|
|
|
|
(defun git/init-git-timemachine ()
|
|
|
|
(use-package git-timemachine
|
|
|
|
:defer t
|
2015-02-22 05:05:20 +00:00
|
|
|
:commands spacemacs/time-machine-micro-state
|
2014-12-14 04:59:02 +00:00
|
|
|
:init
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2015-02-22 05:05:20 +00:00
|
|
|
"gt" 'spacemacs/time-machine-micro-state)
|
|
|
|
|
|
|
|
:config
|
|
|
|
(progn
|
2015-02-22 06:46:36 +00:00
|
|
|
|
2015-02-22 05:05:20 +00:00
|
|
|
(spacemacs|define-micro-state time-machine
|
2015-03-04 16:10:04 +00:00
|
|
|
:doc "[p] [N] previous [n] next [c] current [Y] copy hash [q] quit"
|
2015-10-20 01:21:31 +00:00
|
|
|
:on-enter (let (golden-ratio-mode)
|
|
|
|
(unless (bound-and-true-p git-timemachine-mode)
|
|
|
|
(call-interactively 'git-timemachine)))
|
|
|
|
:on-exit (when (bound-and-true-p git-timemachine-mode)
|
|
|
|
(git-timemachine-quit))
|
2015-02-22 05:05:20 +00:00
|
|
|
:persistent t
|
|
|
|
:bindings
|
|
|
|
("c" git-timemachine-show-current-revision)
|
|
|
|
("p" git-timemachine-show-previous-revision)
|
|
|
|
("n" git-timemachine-show-next-revision)
|
2015-02-22 06:46:36 +00:00
|
|
|
("N" git-timemachine-show-previous-revision)
|
2015-03-03 09:01:05 +00:00
|
|
|
("Y" git-timemachine-kill-revision)
|
2015-02-22 06:46:36 +00:00
|
|
|
("q" nil :exit t)))))
|
2014-12-14 04:59:02 +00:00
|
|
|
|
2015-03-26 16:10:54 +00:00
|
|
|
(defun git/init-gitattributes-mode ()
|
|
|
|
(use-package gitattributes-mode
|
|
|
|
:defer t))
|
|
|
|
|
2015-03-28 03:51:08 +00:00
|
|
|
(defun git/init-gitconfig-mode ()
|
|
|
|
(use-package gitconfig-mode
|
|
|
|
:defer t))
|
|
|
|
|
2015-03-26 16:10:54 +00:00
|
|
|
(defun git/init-gitignore-mode ()
|
|
|
|
(use-package gitignore-mode
|
|
|
|
:defer t))
|
|
|
|
|
2014-12-14 04:59:02 +00:00
|
|
|
(defun git/init-magit ()
|
|
|
|
(use-package magit
|
2015-07-02 04:36:26 +00:00
|
|
|
:commands (magit-status
|
|
|
|
magit-blame-mode
|
|
|
|
magit-log
|
|
|
|
magit-commit)
|
2014-12-14 04:59:02 +00:00
|
|
|
:init
|
2015-03-23 03:11:00 +00:00
|
|
|
(progn
|
2015-07-02 04:36:26 +00:00
|
|
|
(setq magit-completing-read-function 'magit-builtin-completing-read)
|
2015-04-22 10:44:28 +00:00
|
|
|
(add-hook 'git-commit-mode-hook 'fci-mode)
|
2015-04-04 10:36:50 +00:00
|
|
|
;; 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
|
2015-04-11 17:22:37 +00:00
|
|
|
(when (eq window-system 'w32)
|
|
|
|
(setenv "GIT_ASKPASS" "git-gui--askpass"))
|
2015-06-16 01:55:57 +00:00
|
|
|
|
|
|
|
(defun spacemacs/magit-diff-head ()
|
|
|
|
"Execute `magit-diff' against current HEAD."
|
|
|
|
(interactive)
|
|
|
|
(magit-diff "HEAD"))
|
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2015-10-19 03:36:03 +00:00
|
|
|
"gb" 'spacemacs/git-blame-micro-state
|
2015-11-02 05:16:13 +00:00
|
|
|
"gc" 'magit-commit
|
|
|
|
"gC" 'magit-checkout
|
|
|
|
"gdh" 'spacemacs/magit-diff-head
|
2015-10-22 18:51:16 +00:00
|
|
|
"gi" 'magit-init
|
2015-07-02 06:41:10 +00:00
|
|
|
"gl" 'magit-log-all
|
2015-07-02 04:36:26 +00:00
|
|
|
"gL" 'magit-log-buffer-file
|
2015-11-02 05:16:13 +00:00
|
|
|
"gs" 'magit-status)
|
2015-10-19 03:36:03 +00:00
|
|
|
|
|
|
|
(spacemacs|define-micro-state git-blame
|
|
|
|
:doc (concat "Press [b] again to blame further in the history, "
|
|
|
|
"[q] to go up or quit.")
|
2015-10-20 01:10:25 +00:00
|
|
|
:on-enter (let (golden-ratio-mode)
|
|
|
|
(unless (bound-and-true-p magit-blame-mode)
|
|
|
|
(call-interactively 'magit-blame)))
|
2015-10-19 03:36:03 +00:00
|
|
|
:persistent t
|
|
|
|
:bindings
|
|
|
|
("b" magit-blame)
|
|
|
|
;; here we use the :exit keyword because we should exit the
|
|
|
|
;; micro-state only if the magit-blame-quit effectively disable
|
|
|
|
;; the magit-blame mode.
|
2015-10-20 01:21:01 +00:00
|
|
|
("q" nil :exit (progn (when (bound-and-true-p magit-blame-mode)
|
|
|
|
(magit-blame-quit))
|
|
|
|
(not (bound-and-true-p magit-blame-mode))))))
|
2014-12-14 04:59:02 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-07-02 04:36:26 +00:00
|
|
|
;; seems to be necessary at the time of release
|
|
|
|
(require 'git-rebase)
|
2015-10-28 13:13:11 +00:00
|
|
|
|
2015-11-19 05:56:25 +00:00
|
|
|
(unless (configuration-layer/package-usedp 'evil-magit)
|
|
|
|
;; use auto evilification if `evil-magit' is not used
|
2015-11-19 05:24:27 +00:00
|
|
|
(evilified-state-evilify-map magit-mode-map)
|
|
|
|
(evilified-state-evilify-map magit-status-mode-map
|
|
|
|
:mode magit-status-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-refs-mode-map
|
|
|
|
:mode magit-refs-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-blame-mode-map
|
|
|
|
:mode magit-blame-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-hunk-section-map
|
|
|
|
:mode magit-status-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-diff-mode-map
|
|
|
|
:mode magit-diff-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-log-read-revs-map
|
|
|
|
:mode magit-log-read-revs
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-log-mode-map
|
|
|
|
:mode magit-log-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-log-select-mode-map
|
|
|
|
:mode magit-log-select-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-cherry-mode-map
|
|
|
|
:mode magit-cherry-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-reflog-mode-map
|
|
|
|
:mode magit-reflog-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-process-mode-map
|
|
|
|
:mode magit-process-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map magit-stash-mode-map
|
|
|
|
:mode magit-stash-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward)
|
|
|
|
(evilified-state-evilify-map git-rebase-mode-map
|
|
|
|
:mode git-rebase-mode
|
|
|
|
:bindings
|
|
|
|
(kbd "C-S-j") 'magit-section-forward
|
|
|
|
(kbd "C-S-k") 'magit-section-backward
|
|
|
|
(kbd "C-n") 'magit-section-forward
|
|
|
|
(kbd "C-p") 'magit-section-backward
|
|
|
|
"J" 'git-rebase-move-line-down
|
|
|
|
"K" 'git-rebase-move-line-up
|
|
|
|
"u" 'git-rebase-undo
|
|
|
|
"y" 'git-rebase-insert)
|
|
|
|
;;defaultstateforadditionalmodes
|
|
|
|
(dolist (mode '(magit-popup-mode
|
|
|
|
magit-popup-sequence-mode))
|
|
|
|
(add-to-list 'evil-emacs-state-modes mode))
|
|
|
|
(evilified-state--configure-default-state 'magit-revision-mode)
|
|
|
|
;;sectionmaps
|
|
|
|
(evilified-state-evilify-map magit-tag-section-map)
|
|
|
|
(evilified-state-evilify-map magit-untracked-section-map)
|
|
|
|
(evilified-state-evilify-map magit-branch-section-map)
|
|
|
|
(evilified-state-evilify-map magit-remote-section-map)
|
|
|
|
(evilified-state-evilify-map magit-file-section-map)
|
|
|
|
(evilified-state-evilify-map magit-hunk-section-map)
|
|
|
|
(evilified-state-evilify-map magit-unstaged-section-map)
|
|
|
|
(evilified-state-evilify-map magit-staged-section-map)
|
|
|
|
(evilified-state-evilify-map magit-commit-section-map)
|
|
|
|
(evilified-state-evilify-map magit-module-commit-section-map)
|
|
|
|
(evilified-state-evilify-map magit-unpulled-section-map)
|
|
|
|
(evilified-state-evilify-map magit-unpushed-section-map)
|
|
|
|
(evilified-state-evilify-map magit-stashes-section-map)
|
|
|
|
(evilified-state-evilify-map magit-stash-section-map))
|
2015-07-02 04:36:26 +00:00
|
|
|
|
2015-01-04 17:11:13 +00:00
|
|
|
;; full screen magit-status
|
|
|
|
(when git-magit-status-fullscreen
|
2015-10-09 15:25:18 +00:00
|
|
|
(setq magit-display-buffer-function
|
2015-07-02 04:36:26 +00:00
|
|
|
(lambda (buffer)
|
2015-10-09 15:25:18 +00:00
|
|
|
(if (or
|
|
|
|
;; the original should stay alive, so we can't go fullscreen
|
|
|
|
magit-display-buffer-noselect
|
|
|
|
;; don't go fullscreen for certain magit buffers if current
|
|
|
|
;; buffer is a magit buffer (we're conforming to
|
|
|
|
;; `magit-display-buffer-traditional')
|
|
|
|
(and (derived-mode-p 'magit-mode)
|
|
|
|
(not (memq (with-current-buffer buffer major-mode)
|
|
|
|
'(magit-process-mode
|
|
|
|
magit-revision-mode
|
|
|
|
magit-diff-mode
|
|
|
|
magit-stash-mode
|
|
|
|
magit-status-mode)))))
|
|
|
|
;; open buffer according to original magit rules
|
|
|
|
(magit-display-buffer-traditional buffer)
|
|
|
|
;; open buffer in fullscreen
|
|
|
|
(delete-other-windows)
|
|
|
|
;; make sure the window isn't dedicated, otherwise
|
|
|
|
;; `set-window-buffer' throws an error
|
|
|
|
(set-window-dedicated-p nil nil)
|
|
|
|
(set-window-buffer nil buffer)
|
|
|
|
;; return buffer's window
|
|
|
|
(get-buffer-window buffer)))))
|
2015-07-02 04:36:26 +00:00
|
|
|
|
2015-10-28 13:13:11 +00:00
|
|
|
(when dotspacemacs-major-mode-leader-key
|
|
|
|
(add-hook 'with-editor-mode-hook 'evil-normalize-keymaps)
|
|
|
|
(evil-define-key 'normal with-editor-mode-map
|
|
|
|
(concat dotspacemacs-major-mode-leader-key "c") 'with-editor-finish
|
|
|
|
(concat dotspacemacs-major-mode-leader-key "a") 'with-editor-cancel)
|
|
|
|
(evil-define-key 'motion with-editor-mode-map
|
|
|
|
(concat dotspacemacs-major-mode-leader-key "c") 'with-editor-finish
|
|
|
|
(concat dotspacemacs-major-mode-leader-key "a") 'with-editor-cancel))
|
2014-12-14 04:59:02 +00:00
|
|
|
|
2015-07-02 04:36:26 +00:00
|
|
|
;; whitespace
|
2014-12-14 04:59:02 +00:00
|
|
|
(defun magit-toggle-whitespace ()
|
|
|
|
(interactive)
|
2015-07-02 04:36:26 +00:00
|
|
|
(if (member "-w" (if (derived-mode-p 'magit-diff-mode)
|
|
|
|
magit-refresh-args
|
|
|
|
magit-diff-section-arguments))
|
2014-12-14 04:59:02 +00:00
|
|
|
(magit-dont-ignore-whitespace)
|
|
|
|
(magit-ignore-whitespace)))
|
|
|
|
(defun magit-ignore-whitespace ()
|
|
|
|
(interactive)
|
2015-07-02 04:36:26 +00:00
|
|
|
(add-to-list (if (derived-mode-p 'magit-diff-mode)
|
|
|
|
'magit-refresh-args 'magit-diff-section-arguments) "-w")
|
2014-12-14 04:59:02 +00:00
|
|
|
(magit-refresh))
|
|
|
|
(defun magit-dont-ignore-whitespace ()
|
|
|
|
(interactive)
|
2015-07-02 04:36:26 +00:00
|
|
|
(setq magit-diff-options
|
|
|
|
(remove "-w"
|
|
|
|
(if (derived-mode-p 'magit-diff-mode)
|
|
|
|
magit-refresh-args
|
|
|
|
magit-diff-section-arguments))) (magit-refresh))
|
|
|
|
(define-key magit-status-mode-map (kbd "C-S-w")
|
|
|
|
'magit-toggle-whitespace))))
|
2014-12-14 04:59:02 +00:00
|
|
|
|
|
|
|
(defun git/init-magit-gitflow ()
|
|
|
|
(use-package magit-gitflow
|
|
|
|
:commands turn-on-magit-gitflow
|
2015-08-04 20:26:22 +00:00
|
|
|
:init (progn
|
|
|
|
(add-hook 'magit-mode-hook 'turn-on-magit-gitflow)
|
2015-09-29 05:07:57 +00:00
|
|
|
(with-eval-after-load 'magit
|
2015-10-22 12:47:54 +00:00
|
|
|
(define-key magit-mode-map "%" 'magit-gitflow-popup)))
|
2014-12-14 04:59:02 +00:00
|
|
|
:config (spacemacs|diminish magit-gitflow-mode "Flow")))
|
|
|
|
|
2015-01-27 05:17:51 +00:00
|
|
|
(defun git/init-magit-svn ()
|
|
|
|
(use-package magit-svn
|
2015-01-27 05:23:14 +00:00
|
|
|
:if git-enable-magit-svn-plugin
|
2015-01-27 05:17:51 +00:00
|
|
|
: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))))
|
|
|
|
|
2014-12-14 04:59:02 +00:00
|
|
|
(defun git/init-smeargle ()
|
|
|
|
(use-package smeargle
|
|
|
|
:defer t
|
|
|
|
:init
|
2015-08-07 01:40:28 +00:00
|
|
|
(progn
|
2015-11-02 05:16:13 +00:00
|
|
|
(spacemacs/declare-prefix "gH" "highlight")
|
|
|
|
(when (configuration-layer/package-usedp 'which-key)
|
|
|
|
;; TODO abstract this to a function
|
|
|
|
(let ((descr
|
|
|
|
'(("smeargle" . "highlight by last update time")
|
|
|
|
("smeargle-commits" . "highlight by age of changes")
|
|
|
|
("smeargle-clear" . "clear"))))
|
|
|
|
(dolist (nd descr)
|
|
|
|
;; ensure the target matches the whole string
|
|
|
|
(push (cons (concat "\\`" (car nd) "\\'") (cdr nd))
|
|
|
|
which-key-description-replacement-alist))))
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2015-11-02 05:16:13 +00:00
|
|
|
"gHc" 'smeargle-clear
|
|
|
|
"gHh" 'smeargle-commits
|
|
|
|
"gHt" 'smeargle))))
|