Skip to content

Latest commit

 

History

History
229 lines (195 loc) · 10.9 KB

File metadata and controls

229 lines (195 loc) · 10.9 KB

Version-Control layer

Table of Contents

Description

This layers adds general configuration for Emacs VC. It should work with all VC backends such as Git, Mercurial, Bazaar, SVN, etc…

Features:

  • highlights uncommitted changes in the fringe or margin with diff-hl, git-gutter, or git-gutter+
  • adds vcs transient-state SPC g. to allow quick navigation and modification of buffer hunks.

Install

Layer

To use this configuration layer, add it to your ~/.spacemacs. You will need to add version-control to the existing dotspacemacs-configuration-layers list in this file.

Configuration

You can choose the package to facilitate the diff transient-state and show margins by setting version-control-diff-tool

'(version-control :variables
                  version-control-diff-tool 'diff-hl)

You can choose the side on which the diff appears (by default it’s the right side)

'(version-control :variables
                  version-control-diff-side 'left)

To automatically enable diff margins in all buffers, set version-control-global-margin

'(version-control :variables
                  version-control-global-margin t)

Differences between margin programs

This layer contains generalized mappings for three diff margin packages: diff-hl, git-gutter, and git-gutter+.

There are some differences between packages that might have some people prefer one over the other:

Featurediff-hlgit-guttergit-gutter+
Show in fringeXXX
Extended VCS support (e.g. hg, svn)XX
Stage hunks from bufferXX
Dired supportX

Key bindings

VC commands:

Key bindingDescription
SPC g .version control transient-state
SPC g rsmerge mode transient-state
SPC g h obrowser at remote
SPC g v =open a hunk under the point in the diff buffer
SPC g v Dcompare the entire working tree with head
SPC g v eshow diff against current head using ediff
SPC g v gvisually annotate the current file
SPC g v dopen the VC Directory buffer
SPC g v +update the working copy
SPC g v iregister (add) into a version control system
SPC g v urevert working copy to their repository contents
SPC g v llist the change log
SPC g v Llist the change log for the current VC controlled tree
SPC g v vdo the next logical VC operation (vc-next-action)
SPC g v Iignore file (vc-ignore)
SPC g v rresolve conflicts in file

VC Directory buffer commands

You can hit SPC pv from the current project to open the VC Directory buffer, or use SPC g v d for specifying a root directory. Then you may mark (m key) files you are interested in, to form a fileset. Most commands described above are applicable to filesets too. To some of them are given shortcuts:

KeyDescription
=compare selected files with head
copen a commit message buffer
llist changes
aannotate selected files
iadd into a version control system
rrefresh directory view
Eignore file under cursor

Navigation and interaction commands in the VC Directory buffer:

Key bindingsDescription
j or M-nnext file
k or M-pprevious file
gj or TABnext directory
gk or S-TABprevious directory
mmark a file
uunmark a file

Commit message editing buffer

In a commit message buffer press C-c C-c to commit the changes with the entered message. Pressing C-c C-k will discard the commit message and close this buffer.

Diff mode

Key bindingsDescription
SPC m aapply a hunk
SPC m dkill the hunk at point
SPC m Dkill the current file’s hunk
SPC m ecall ediff-patch-file on current buffer
SPC m f cconvert unified diffs to context diffs
SPC m f rreverse the direction of the diffs
SPC m f uconvert context diffs to unified diffs
SPC m gjump to the corresponding source line
SPC m jnext hunk
SPC m Jnext file
SPC m kprevious hunk
SPC m Kprevious file
SPC m qclose the diff window
SPC m rrevert a hunk
SPC m ssplit the current hunk at point into two hunks
SPC m uundo

A transient buffer is also defined, start it with SPC m . or , .

Key bindingsDescription
jnext hunk
Jnext file
kprevious hunk
Kprevious file

Log view buffer

Key bindingsDescription
C-j or M-nnext message
C-k or M-pprevious message
gj or J or TABnext file
gk or K or S-TABprevious file
f or ENTERvisit the version at point
ddisplay a diff between the revision at point and the next earlier revision
ouse for jumping to links
Htoggle hiding of the full message

Annotation buffer

Key bindingsDescription
Jvisit the annotation of the revision after this one
Kvisit the annotation of the revision previous to this one
LVisit the log of the revision at line
Htoggle whether or not the annotation is visible
avisit the annotation of the revision identified in the current line
pvisit the annotation of the revision before the revision at line
ddisplay the diff between the current line’s revision and the previous revision
fshow in a buffer the file revision indicated by the current line

Version Control Transient-state

Use SPC g . to enter a transient state for quickly navigating between hunks in a buffer. During that state, the following bindings are active:

Key bindingDescription
hShow diff of hunk
nNext hunk
N or pPrevious hunk
rRevert hunk
sStage hunk
tToggle margin indicators
wStage file
uUnstage file
dRepo diff popup
DShow diffs of unstaged hunks
cCommit with popup
CCommit
PPush repo with popup
fFetch for repo with popup
FPull repo with popup
lShow repo log
zRecenter buffer in window

Smerge Mode Transient-state

Key bindingDescription
SPC g r nNext hunk
SPC g r NPrevious hunk
SPC g r pPrevious hunk
SPC g r jGo to next line
SPC g r kGo to previous line
SPC g r bSmerge keep base
SPC g r mSmerge keep mine
SPC g r aSmerge keep all
SPC g r oSmerge keep other
SPC g r cSmerge keep current
SPC g r CSmerge combine with next
SPC g r uUndo
SPC g r rSmerge refine
SPC g r qQuit transient state

Toggles

Key bindingDescription
SPC T dtoggle diff margins
SPC T C-dtoggle diff margins globally