2015-06-10 02:19:16 +00:00
|
|
|
;;; packages.el --- Source Control Layer packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-06-10 02:19:16 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq version-control-packages
|
|
|
|
'(
|
2017-03-29 11:29:22 +00:00
|
|
|
browse-at-remote
|
2016-02-22 18:18:48 +00:00
|
|
|
(vc :location built-in)
|
2015-06-10 02:19:16 +00:00
|
|
|
diff-mode
|
2015-11-15 19:01:58 +00:00
|
|
|
diff-hl
|
2016-05-06 11:27:44 +00:00
|
|
|
evil-unimpaired
|
2015-11-15 19:01:58 +00:00
|
|
|
git-gutter
|
|
|
|
git-gutter+
|
|
|
|
git-gutter-fringe
|
|
|
|
git-gutter-fringe+
|
2017-03-12 13:22:03 +00:00
|
|
|
(smerge-mode :location built-in)
|
2015-11-15 19:01:58 +00:00
|
|
|
))
|
2015-06-10 02:19:16 +00:00
|
|
|
|
2016-02-22 18:18:48 +00:00
|
|
|
(defun version-control/init-vc ()
|
|
|
|
(use-package vc
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-02-22 18:18:48 +00:00
|
|
|
:init
|
|
|
|
(spacemacs/declare-prefix "gv" "version-control")
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs/set-leader-keys
|
|
|
|
"gvv" 'vc-next-action
|
|
|
|
"gvg" 'vc-annotate
|
|
|
|
"gvD" 'vc-root-diff
|
|
|
|
"gve" 'vc-ediff
|
|
|
|
"gvd" 'vc-dir
|
|
|
|
"gv+" 'vc-update
|
|
|
|
"gvi" 'vc-register
|
|
|
|
"gvu" 'vc-revert
|
|
|
|
"gvl" 'vc-print-log
|
|
|
|
"gvL" 'vc-print-root-log
|
|
|
|
"gvI" 'vc-ignore
|
|
|
|
"gvr" 'vc-resolve-conflicts)
|
|
|
|
|
|
|
|
(evilified-state-evilify vc-dir-mode vc-dir-mode-map
|
|
|
|
"j" 'vc-dir-next-line
|
|
|
|
(kbd "M-n") 'vc-dir-next-line
|
|
|
|
"k" 'vc-dir-previous-line
|
|
|
|
(kbd "M-p") 'vc-dir-previous-line
|
|
|
|
"gj" 'vc-dir-next-directory
|
|
|
|
(kbd "<tab>") 'vc-dir-next-directory
|
|
|
|
"gk" 'vc-dir-previous-directory
|
|
|
|
(kbd "<backtab>") 'vc-dir-previous-directory
|
|
|
|
"l" 'vc-print-log
|
|
|
|
"c" 'vc-next-action
|
|
|
|
"a" 'vc-annotate
|
|
|
|
"r" 'vc-dir-refresh
|
|
|
|
"E" 'vc-dir-ignore)
|
|
|
|
|
|
|
|
(evilified-state-evilify log-view-mode log-view-mode-map
|
|
|
|
(kbd "M-n") 'log-view-msg-next
|
|
|
|
(kbd "M-p") 'log-view-msg-prev
|
|
|
|
(kbd "C-j") 'log-view-msg-next
|
|
|
|
(kbd "C-k") 'log-view-msg-prev
|
|
|
|
"J" 'log-view-file-next
|
|
|
|
(kbd "<tab>") 'log-view-file-next
|
|
|
|
"gj" 'log-view-file-next
|
|
|
|
"K" 'log-view-file-prev
|
|
|
|
"gk" 'log-view-file-prev
|
|
|
|
(kbd "<backtab>") 'log-view-file-prev
|
|
|
|
(kbd "<return>") 'log-view-find-revision
|
|
|
|
"H" 'log-view-toggle-entry-display
|
|
|
|
"o" 'ace-link-woman)
|
|
|
|
(evilified-state-evilify vc-svn-log-view-mode vc-svn-log-view-mode-map)
|
|
|
|
(evilified-state-evilify vc-git-log-view-mode vc-git-log-view-mode-map)
|
|
|
|
(evilified-state-evilify vc-hg-log-view-mode vc-git-log-view-mode-map)
|
|
|
|
(evilified-state-evilify vc-annotate-mode vc-annotate-mode-map
|
|
|
|
"J" 'vc-annotate-next-revision
|
|
|
|
"K" 'vc-annotate-prev-revision
|
|
|
|
"L" 'vc-annotate-show-log-revision-at-line
|
|
|
|
"H" 'vc-annotate-toggle-annotation-visibility
|
|
|
|
"a" 'vc-annotate-revision-at-line
|
|
|
|
"p" 'vc-annotate-revision-previous-to-line))))
|
|
|
|
|
|
|
|
|
2015-06-10 02:19:16 +00:00
|
|
|
(defun version-control/init-diff-mode ()
|
|
|
|
(use-package diff-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-02-22 18:18:48 +00:00
|
|
|
:config
|
diff-mode: define key bindings with leader key for vim editing style
This patch defines key bindings with leader key instead of evilified state to
make it easier for people those who edit in vim style to use diff-mode for both
of editing and reviewing files/buffers.
There are two use cases for diff-mode:
(1) to manually edit diff in a patch file
(2) to review diff that is generated by `vc-diff' or similar commands
The evilified state is useful for the case (2), but is confusing for the
case (1). Usually, users of vim editing style expect that they are in normal
state when a new buffer is created. However, when evilified state is used for
the case (1), some keys insert their character in a buffer, which let the users
think they are in insert state and keep hitting keys to edit the buffer, while
other keys invoke commands or change contents of buffer, which let them think
they are in normal state, so finally the user get lost what state they are in if
they don't know evilified state is used for diff-mode.
The changeset 58d521af5 "Unbreak diff-mode", originally written on Apr 2 2017,
tried to avoid the confusion by removing the evilified state configuration.
However, it is overwritten by the other and older changeset 8009e1bf5 "evilify
vc-* buffers", which is written on Feb 22 2016, for some reason.
This patch respects both of the use cases listed above, thus defines key
bindings with leader key instead of just removing the evilified state
configuration.
2018-06-19 14:41:18 +00:00
|
|
|
(progn
|
|
|
|
(spacemacs/declare-prefix-for-mode 'diff-mode "mf" "format")
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'diff-mode
|
|
|
|
"a" 'diff-apply-hunk
|
|
|
|
"d" 'diff-hunk-kill
|
|
|
|
"D" 'diff-file-kill
|
|
|
|
"e" 'diff-ediff-patch
|
|
|
|
"fc" 'diff-unified->context
|
|
|
|
"fr" 'diff-reverse-direction
|
|
|
|
"fu" 'diff-context->unified
|
|
|
|
"g" 'diff-goto-source
|
|
|
|
"j" 'diff-hunk-next
|
|
|
|
"J" 'diff-file-next
|
|
|
|
"k" 'diff-hunk-prev
|
|
|
|
"K" 'diff-file-prev
|
|
|
|
"r" 'spacemacs/diff-mode-revert-hunk
|
|
|
|
"s" 'diff-split-hunk
|
|
|
|
"u" 'diff-undo
|
|
|
|
"q" 'quit-window)
|
|
|
|
(spacemacs|define-transient-state diff-mode
|
|
|
|
:title "Diff-mode Transient State"
|
|
|
|
:evil-leader-for-mode (diff-mode . ".")
|
|
|
|
:bindings
|
|
|
|
("j" diff-hunk-next "next hunk")
|
|
|
|
("J" diff-file-next "next file")
|
|
|
|
("k" diff-hunk-prev "previous hunk")
|
|
|
|
("K" diff-file-prev "previous file")
|
|
|
|
("q" nil "quit" :exit t)
|
|
|
|
("<escape>" nil nil :exit t)))))
|
2015-06-10 02:19:16 +00:00
|
|
|
|
|
|
|
(defun version-control/init-diff-hl ()
|
|
|
|
(use-package diff-hl
|
2018-06-14 06:51:24 +00:00
|
|
|
:if (eq version-control-diff-tool 'diff-hl)
|
2018-06-14 14:07:24 +00:00
|
|
|
:defer t
|
2015-06-10 02:19:16 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-02-22 18:18:48 +00:00
|
|
|
(spacemacs/set-leader-keys "gv=" 'diff-hl-diff-goto-hunk)
|
2018-06-11 03:30:48 +00:00
|
|
|
(if version-control-global-margin
|
2018-06-14 06:51:24 +00:00
|
|
|
(progn
|
|
|
|
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
|
|
|
|
(run-with-idle-timer 1 nil 'global-diff-hl-mode))
|
|
|
|
(run-with-idle-timer 1 nil 'diff-hl-margin-mode)))
|
|
|
|
:config
|
|
|
|
(progn
|
2018-06-11 03:30:48 +00:00
|
|
|
(spacemacs|do-after-display-system-init
|
|
|
|
(setq diff-hl-side (if (eq version-control-diff-side 'left)
|
2019-01-20 04:40:33 +00:00
|
|
|
'left 'right))))))
|
2015-11-15 19:01:58 +00:00
|
|
|
|
2016-05-06 11:27:44 +00:00
|
|
|
(defun version-control/post-init-evil-unimpaired ()
|
2016-07-07 00:59:06 +00:00
|
|
|
(define-key evil-normal-state-map (kbd "[ h") 'spacemacs/vcs-previous-hunk)
|
|
|
|
(define-key evil-normal-state-map (kbd "] h") 'spacemacs/vcs-next-hunk))
|
2016-05-06 11:27:44 +00:00
|
|
|
|
2015-11-15 19:01:58 +00:00
|
|
|
(defun version-control/init-git-gutter ()
|
|
|
|
(use-package git-gutter
|
2018-06-14 06:51:24 +00:00
|
|
|
:if (eq version-control-diff-tool 'git-gutter)
|
2018-06-14 14:07:24 +00:00
|
|
|
:defer t
|
2015-11-15 19:01:58 +00:00
|
|
|
:init
|
2015-11-30 22:33:07 +00:00
|
|
|
(progn
|
|
|
|
;; If you enable global minor mode
|
2018-06-14 06:51:24 +00:00
|
|
|
(when version-control-global-margin
|
2017-08-11 20:52:53 +00:00
|
|
|
(run-with-idle-timer 1 nil 'global-git-gutter-mode))
|
2015-11-30 22:33:07 +00:00
|
|
|
(setq git-gutter:update-interval 2
|
|
|
|
git-gutter:modified-sign " "
|
|
|
|
git-gutter:added-sign "+"
|
|
|
|
git-gutter:deleted-sign "-"
|
|
|
|
git-gutter:diff-option "-w"
|
|
|
|
git-gutter:hide-gutter t
|
|
|
|
git-gutter:ask-p nil
|
|
|
|
git-gutter:verbosity 0
|
|
|
|
git-gutter:handled-backends '(git hg bzr svn)
|
|
|
|
git-gutter:hide-gutter t))
|
|
|
|
:config
|
2015-11-15 19:01:58 +00:00
|
|
|
(spacemacs|hide-lighter git-gutter-mode)))
|
|
|
|
|
|
|
|
(defun version-control/init-git-gutter-fringe ()
|
|
|
|
(use-package git-gutter-fringe
|
2018-06-14 14:07:24 +00:00
|
|
|
:if (eq version-control-diff-tool 'git-gutter)
|
|
|
|
:defer t
|
2015-11-15 19:01:58 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-08-28 19:10:13 +00:00
|
|
|
(spacemacs|do-after-display-system-init
|
|
|
|
(with-eval-after-load 'git-gutter
|
|
|
|
(require 'git-gutter-fringe)))
|
2016-11-05 11:03:23 +00:00
|
|
|
(setq git-gutter-fr:side (if (eq version-control-diff-side 'left)
|
2016-11-01 09:27:45 +00:00
|
|
|
'left-fringe 'right-fringe)))
|
2015-11-15 19:01:58 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; 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..."
|
|
|
|
"XX.XX.."
|
|
|
|
".XXX..."
|
|
|
|
"..X...."
|
|
|
|
))))
|
|
|
|
|
|
|
|
(defun version-control/init-git-gutter+ ()
|
|
|
|
(use-package git-gutter+
|
2018-06-14 06:51:24 +00:00
|
|
|
:if (eq version-control-diff-tool 'git-gutter+)
|
2018-06-14 14:07:24 +00:00
|
|
|
:defer t
|
2015-11-15 19:01:58 +00:00
|
|
|
:init
|
2015-11-30 22:33:07 +00:00
|
|
|
(progn
|
|
|
|
;; If you enable global minor mode
|
2018-06-14 06:51:24 +00:00
|
|
|
(when version-control-global-margin
|
2015-11-30 22:33:07 +00:00
|
|
|
(add-hook 'magit-pre-refresh-hook 'git-gutter+-refresh)
|
2017-08-11 20:52:53 +00:00
|
|
|
(run-with-idle-timer 1 nil 'global-git-gutter+-mode))
|
2015-11-30 22:33:07 +00:00
|
|
|
(setq
|
|
|
|
git-gutter+-modified-sign " "
|
|
|
|
git-gutter+-added-sign "+"
|
|
|
|
git-gutter+-deleted-sign "-"
|
|
|
|
git-gutter+-diff-option "-w"
|
|
|
|
git-gutter+-hide-gutter t))
|
2015-11-15 19:01:58 +00:00
|
|
|
;; identify magit changes
|
|
|
|
:config
|
2015-11-30 22:33:07 +00:00
|
|
|
(spacemacs|hide-lighter git-gutter+-mode)
|
2015-11-15 19:01:58 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
(defun version-control/init-git-gutter-fringe+ ()
|
|
|
|
(use-package git-gutter-fringe+
|
2018-06-14 06:51:24 +00:00
|
|
|
:if (eq version-control-diff-tool 'git-gutter+)
|
2018-06-14 14:07:24 +00:00
|
|
|
:defer t
|
2015-11-15 19:01:58 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-08-28 19:10:13 +00:00
|
|
|
(spacemacs|do-after-display-system-init
|
|
|
|
(with-eval-after-load 'git-gutter+
|
|
|
|
(require 'git-gutter-fringe+)))
|
2016-11-05 11:03:23 +00:00
|
|
|
(setq git-gutter-fr+-side (if (eq version-control-diff-side 'left)
|
2016-11-01 09:27:45 +00:00
|
|
|
'left-fringe 'right-fringe)))
|
2015-11-15 19:01:58 +00:00
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
;; 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..."
|
|
|
|
"XX.XX.."
|
|
|
|
".XXX..."
|
|
|
|
"..X...."
|
|
|
|
))))
|
2017-03-12 13:22:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
(defun version-control/init-smerge-mode ()
|
|
|
|
(use-package smerge-mode
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-03-12 13:22:03 +00:00
|
|
|
:diminish smerge-mode
|
|
|
|
:commands spacemacs/smerge-transient-state/body
|
|
|
|
:init
|
|
|
|
(spacemacs/set-leader-keys
|
|
|
|
"gr" 'spacemacs/smerge-transient-state/body)
|
|
|
|
:config
|
|
|
|
(progn
|
|
|
|
(spacemacs|define-transient-state smerge
|
2019-04-20 09:05:30 +00:00
|
|
|
:title "Smerge Transient State"
|
2017-03-12 13:22:03 +00:00
|
|
|
:doc "
|
2019-04-21 09:20:01 +00:00
|
|
|
Movement^^^^ Merge Action^^ Diff^^ Other
|
|
|
|
---------------^^^^ ----------------^^ --------------^^ ---------------------------^^
|
|
|
|
[_n_]^^ next hunk [_b_] keep base [_<_] base/mine [_C_] combine curr/next hunks
|
|
|
|
[_N_/_p_] prev hunk [_m_] keep mine [_=_] mine/other [_u_] undo
|
|
|
|
[_j_]^^ next line [_a_] keep all [_>_] base/other [_q_] quit
|
|
|
|
[_k_]^^ prev line [_o_] keep other [_r_] refine
|
|
|
|
^^^^ [_c_] keep current [_e_] ediff
|
2019-04-20 14:16:04 +00:00
|
|
|
^^^^ [_K_] kill current"
|
2017-03-12 13:22:03 +00:00
|
|
|
:bindings
|
2019-04-20 14:16:04 +00:00
|
|
|
;; move
|
2017-03-12 13:22:03 +00:00
|
|
|
("n" smerge-next)
|
|
|
|
("N" smerge-prev)
|
2019-04-20 14:16:04 +00:00
|
|
|
("p" smerge-prev)
|
2017-03-12 13:22:03 +00:00
|
|
|
("j" evil-next-line)
|
|
|
|
("k" evil-previous-line)
|
2019-04-20 14:16:04 +00:00
|
|
|
;; merge action
|
2017-03-12 13:22:03 +00:00
|
|
|
("b" smerge-keep-base)
|
|
|
|
("m" smerge-keep-mine)
|
2019-04-20 14:16:04 +00:00
|
|
|
("a" smerge-keep-all)
|
2017-03-12 13:22:03 +00:00
|
|
|
("o" smerge-keep-other)
|
|
|
|
("c" smerge-keep-current)
|
2019-04-20 14:16:04 +00:00
|
|
|
;; diff
|
2019-04-21 09:20:01 +00:00
|
|
|
("<" smerge-diff-base-mine)
|
|
|
|
("=" smerge-diff-mine-other)
|
|
|
|
(">" smerge-diff-base-other)
|
2019-04-20 14:16:04 +00:00
|
|
|
("r" smerge-refine)
|
|
|
|
("e" smerge-ediff :exit t)
|
|
|
|
;; other
|
|
|
|
("C" smerge-combine-with-next)
|
|
|
|
("K" smerge-kill-current)
|
|
|
|
("u" undo-tree-undo)
|
|
|
|
("q" nil :exit t)))))
|
2017-03-29 11:29:22 +00:00
|
|
|
|
|
|
|
(defun version-control/init-browse-at-remote ()
|
|
|
|
(use-package browse-at-remote
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2017-03-29 11:29:22 +00:00
|
|
|
:init (spacemacs/set-leader-keys "gho" 'browse-at-remote)))
|