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
|
|
|
|
|
2014-12-14 04:59:02 +00:00
|
|
|
(defvar git-packages
|
|
|
|
'(
|
2015-03-26 16:10:54 +00:00
|
|
|
gitattributes-mode
|
2015-03-26 06:02:15 +00:00
|
|
|
gitconfig-mode
|
2015-03-26 16:10:54 +00:00
|
|
|
gitignore-mode
|
2015-03-26 06:02:15 +00:00
|
|
|
git-commit-mode
|
2014-12-14 04:59:02 +00:00
|
|
|
git-messenger
|
2015-02-04 01:58:21 +00:00
|
|
|
git-rebase-mode
|
2014-12-14 04:59:02 +00:00
|
|
|
git-timemachine
|
2015-01-27 05:23:14 +00:00
|
|
|
gist
|
|
|
|
github-browse-file
|
|
|
|
;; not up to date
|
|
|
|
;; helm-gist
|
2014-12-14 04:59:02 +00:00
|
|
|
magit
|
2015-01-27 05:23:14 +00:00
|
|
|
magit-gh-pulls
|
2014-12-14 04:59:02 +00:00
|
|
|
magit-gitflow
|
2015-01-27 05:23:14 +00:00
|
|
|
magit-svn
|
2014-12-14 04:59:02 +00:00
|
|
|
smeargle
|
|
|
|
)
|
|
|
|
"List of all packages to install and/or initialize. Built-in packages
|
|
|
|
which require an initialization must be listed explicitly in the list.")
|
|
|
|
|
2015-01-10 03:56:02 +00:00
|
|
|
(if git-gutter-use-fringe
|
|
|
|
(push 'git-gutter-fringe git-packages)
|
|
|
|
(push 'git-gutter git-packages))
|
|
|
|
|
2014-12-14 19:54:14 +00:00
|
|
|
(defun git/init-gist ()
|
|
|
|
(use-package gist
|
2015-01-27 05:23:14 +00:00
|
|
|
:if git-enable-github-support
|
2014-12-14 19:54:14 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(progn
|
2015-03-23 03:11:00 +00:00
|
|
|
(evilify gist-list-menu-mode gist-list-menu-mode-map
|
|
|
|
"f" 'gist-fetch-current
|
|
|
|
"K" 'gist-kill-current
|
|
|
|
"o" 'gist-browse-current-url)
|
2014-12-14 19:54:14 +00:00
|
|
|
|
|
|
|
(evil-leader/set-key
|
|
|
|
"ggb" 'gist-buffer
|
|
|
|
"ggB" 'gist-buffer-private
|
|
|
|
"ggl" 'gist-list
|
|
|
|
"ggr" 'gist-region
|
2015-03-23 03:11:00 +00:00
|
|
|
"ggR" 'gist-region-private))))
|
2014-12-14 19:54:14 +00:00
|
|
|
|
2015-03-28 03:51:08 +00:00
|
|
|
(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)))
|
|
|
|
|
2015-01-10 03:56:02 +00:00
|
|
|
(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)
|
2015-01-11 18:07:37 +00:00
|
|
|
(if (and (not git-gutter-use-fringe)
|
|
|
|
global-linum-mode)
|
|
|
|
(git-gutter:linum-setup)))
|
2015-01-09 01:38:58 +00:00
|
|
|
|
|
|
|
(defun git/init-git-gutter ()
|
|
|
|
(use-package git-gutter
|
|
|
|
:commands git-gutter-mode
|
|
|
|
:init
|
|
|
|
(progn
|
2015-01-10 03:56:02 +00:00
|
|
|
(init-git-gutter)
|
2015-01-09 01:38:58 +00:00
|
|
|
(add-to-hooks 'git-gutter-mode '(markdown-mode-hook
|
|
|
|
org-mode-hook
|
|
|
|
prog-mode-hook)))))
|
|
|
|
|
2014-12-14 04:59:02 +00:00
|
|
|
(defun git/init-git-gutter-fringe ()
|
2014-12-18 16:08:36 +00:00
|
|
|
(use-package git-gutter-fringe
|
2014-12-19 02:27:27 +00:00
|
|
|
:commands git-gutter-mode
|
2014-12-14 04:59:02 +00:00
|
|
|
:init
|
2014-12-19 02:27:27 +00:00
|
|
|
(progn
|
|
|
|
(defun git/load-git-gutter ()
|
2015-01-10 03:56:02 +00:00
|
|
|
"Lazy load git gutter and choose between fringe and no fringe."
|
|
|
|
(when (display-graphic-p) (require 'git-gutter-fringe))
|
|
|
|
(init-git-gutter))
|
2015-02-16 07:59:40 +00:00
|
|
|
(setq git-gutter-fr:side 'right-fringe)
|
2014-12-19 02:27:27 +00:00
|
|
|
(add-to-hooks 'git/load-git-gutter '(markdown-mode-hook
|
|
|
|
org-mode-hook
|
|
|
|
prog-mode-hook)))
|
2014-12-14 04:59:02 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(setq git-gutter:hide-gutter t)
|
|
|
|
;; Don't need log/message.
|
|
|
|
(setq git-gutter:verbosity 0)
|
2014-12-22 05:08:41 +00:00
|
|
|
(evil-leader/set-key
|
2014-12-23 04:18:58 +00:00
|
|
|
"ghs" 'git-gutter:stage-hunk
|
|
|
|
"ghr" 'git-gutter:revert-hunk
|
|
|
|
"ghN" 'git-gutter:previous-hunk
|
|
|
|
"ghn" 'git-gutter:next-hunk)
|
2014-12-14 04:59:02 +00:00
|
|
|
;; (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
|
2015-01-09 01:38:58 +00:00
|
|
|
"..X...."
|
|
|
|
"..X...."
|
|
|
|
"XXXXX.."
|
|
|
|
"..X...."
|
|
|
|
"..X...."
|
|
|
|
)
|
2014-12-14 04:59:02 +00:00
|
|
|
(fringe-helper-define 'git-gutter-fr:deleted nil
|
2015-01-09 01:38:58 +00:00
|
|
|
"......."
|
|
|
|
"......."
|
|
|
|
"XXXXX.."
|
|
|
|
"......."
|
|
|
|
"......."
|
|
|
|
)
|
2014-12-14 04:59:02 +00:00
|
|
|
(fringe-helper-define 'git-gutter-fr:modified nil
|
2015-01-09 01:38:58 +00:00
|
|
|
"..X...."
|
|
|
|
".XXX..."
|
|
|
|
"XXXXX.."
|
|
|
|
".XXX..."
|
|
|
|
"..X...."
|
|
|
|
))))
|
2014-12-14 04:59:02 +00:00
|
|
|
|
|
|
|
(defun git/init-git-messenger ()
|
|
|
|
(use-package git-messenger
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(evil-leader/set-key
|
|
|
|
"gm" 'git-messenger:popup-message)))
|
|
|
|
|
2015-02-04 06:05:54 +00:00
|
|
|
(defun git/init-git-rebase-mode ()
|
2015-02-04 01:58:21 +00:00
|
|
|
(use-package git-rebase-mode
|
|
|
|
:defer t
|
2015-03-28 04:06:52 +00:00
|
|
|
: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))))
|
2015-02-04 01:58:21 +00:00
|
|
|
|
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
|
|
|
|
(evil-leader/set-key
|
2015-02-22 05:05:20 +00:00
|
|
|
"gt" 'spacemacs/time-machine-micro-state)
|
|
|
|
|
|
|
|
:config
|
|
|
|
(progn
|
2015-02-22 06:46:36 +00:00
|
|
|
|
|
|
|
(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))))
|
|
|
|
|
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-02-22 06:46:36 +00:00
|
|
|
:on-enter (spacemacs//time-machine-ms-on-enter)
|
2015-02-22 05:05:20 +00:00
|
|
|
: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)
|
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 19:54:14 +00:00
|
|
|
;; 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))
|
|
|
|
;; ))
|
|
|
|
|
2014-12-14 04:59:02 +00:00
|
|
|
(defun git/init-magit ()
|
|
|
|
(use-package magit
|
|
|
|
:defer t
|
|
|
|
:init
|
2015-03-23 03:11:00 +00:00
|
|
|
(progn
|
2015-04-03 02:42:57 +00:00
|
|
|
(setq magit-last-seen-setup-instructions "1.4.0"
|
|
|
|
magit-completing-read-function 'magit-ido-completing-read)
|
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
|
|
|
|
(setenv "GIT_ASKPASS" "git-gui--askpass")
|
2015-03-23 03:11:00 +00:00
|
|
|
(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))
|
2014-12-14 04:59:02 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|hide-lighter magit-auto-revert-mode)
|
2015-01-04 17:11:13 +00:00
|
|
|
;; 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))
|
2014-12-14 04:59:02 +00:00
|
|
|
|
|
|
|
(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))))
|
|
|
|
|
2014-12-14 19:54:14 +00:00
|
|
|
(defun git/init-magit-gh-pulls ()
|
2015-03-14 20:32:47 +00:00
|
|
|
(use-package magit-gh-pulls
|
2015-01-27 05:23:14 +00:00
|
|
|
:if git-enable-github-support
|
2014-12-14 19:54:14 +00:00
|
|
|
:defer t
|
2015-04-05 18:40:47 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(when (fboundp 'magit-gh-pulls-mode)
|
|
|
|
(eval-after-load 'magit
|
|
|
|
'(define-key magit-mode-map "#gg"
|
|
|
|
#'spacemacs/load-gh-pulls-mode))
|
|
|
|
|
|
|
|
(defun spacemacs/load-gh-pulls-mode ()
|
|
|
|
"Start `magit-gh-pulls-mode' only after a manual request."
|
|
|
|
(interactive)
|
|
|
|
(add-hook 'magit-mode-hook #'turn-on-magit-gh-pulls)
|
|
|
|
(magit-gh-pulls-mode 1)
|
|
|
|
(magit-gh-pulls-reload)))
|
|
|
|
)
|
2014-12-14 19:54:14 +00:00
|
|
|
:config (spacemacs|diminish magit-gh-pulls-mode "Github-PR")))
|
|
|
|
|
2014-12-15 01:16:46 +00:00
|
|
|
(defun git/init-github-browse-file ()
|
|
|
|
(use-package github-browse-file
|
2015-01-27 05:23:14 +00:00
|
|
|
:if git-enable-github-support
|
2014-12-15 01:16:46 +00:00
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(evil-leader/set-key
|
|
|
|
"gfb" 'github-browse-file)))
|
|
|
|
|
2014-12-14 04:59:02 +00:00
|
|
|
(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")))
|
|
|
|
|
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
|
|
|
|
(evil-leader/set-key
|
2014-12-15 02:42:17 +00:00
|
|
|
"ghc" 'smeargle-clear
|
|
|
|
"ghh" 'smeargle-commits
|
|
|
|
"ght" 'smeargle)))
|