[version-control] Use :toggle to avoid installation of unused packages

Usage of the `:if` keyword with `use-package` does not prevent Spacemacs form
installing the package, it only prevents the loading in run-time. This commit
employs the `:toggle` feature of the configuration layer system to prevent the
unneeded packages from being installed in the first place.

This further improves upon 31324f68bb
This commit is contained in:
madand 2019-12-23 23:01:32 +02:00 committed by duianto
parent c7d77dfc46
commit 081d8f29d4
3 changed files with 16 additions and 15 deletions

View File

@ -3133,6 +3133,7 @@ Other:
- =browse-at-remote= which replaces =github-browse-file=
(thanks Eugene Yaremenko)
- Avoid loading all the diff packages (thanks to Sylvain Benner)
- Avoided installing unused diff packages (thanks to Andriy Kmit)
- Fixed error on =diff-hl-margin-mode= function being nil during startup
(thanks to Voleking)
**** Vue

View File

@ -8,7 +8,7 @@
- [[#install][Install]]
- [[#layer][Layer]]
- [[#configuration][Configuration]]
- [[#differences-between-margin-programs][Differences between margin programs]]
- [[#differences-between-margin-packages][Differences between margin packages]]
- [[#key-bindings][Key bindings]]
- [[#vc-directory-buffer-commands][VC Directory buffer commands]]
- [[#commit-message-editing-buffer][Commit message editing buffer]]
@ -34,8 +34,12 @@ add =version-control= to the existing =dotspacemacs-configuration-layers= list i
file.
* Configuration
You can choose the package to facilitate the diff transient-state and show margins
by setting =version-control-diff-tool=
You can choose the package to facilitate the diff transient-state and show
margins by setting the =version-control-diff-tool= variable to one of the
supported packages:
- [[https://github.com/dgutov/diff-hl][diff-hl]]
- [[https://github.com/syohex/emacs-git-gutter][git-gutter]]
- [[https://github.com/nonsequitur/git-gutter-plus][git-gutter+]] (default)
#+BEGIN_SRC emacs-lisp
'(version-control :variables
@ -57,9 +61,9 @@ To automatically enable diff margins in all buffers, set
version-control-global-margin t)
#+END_SRC
** Differences between margin programs
** Differences between margin packages
This layer contains generalized mappings for three diff margin packages:
diff-hl, git-gutter, and git-gutter+.
=diff-hl=, =git-gutter=, and =git-gutter+=.
There are some differences between packages that might have some people prefer
one over the other:

View File

@ -12,15 +12,15 @@
(setq version-control-packages
'(
browse-at-remote
(vc :location built-in)
(diff-hl :toggle (eq 'diff-hl version-control-diff-tool))
diff-mode
diff-hl
evil-unimpaired
git-gutter
git-gutter+
git-gutter-fringe
git-gutter-fringe+
(git-gutter :toggle (eq 'git-gutter version-control-diff-tool))
(git-gutter-fringe :toggle (eq 'git-gutter version-control-diff-tool))
(git-gutter+ :toggle (eq 'git-gutter+ version-control-diff-tool))
(git-gutter-fringe+ :toggle (eq 'git-gutter+ version-control-diff-tool))
(smerge-mode :location built-in)
(vc :location built-in)
))
(defun version-control/init-vc ()
@ -121,7 +121,6 @@
(defun version-control/init-diff-hl ()
(use-package diff-hl
:if (eq version-control-diff-tool 'diff-hl)
:defer t
:init
(progn
@ -143,7 +142,6 @@
(defun version-control/init-git-gutter ()
(use-package git-gutter
:if (eq version-control-diff-tool 'git-gutter)
:defer t
:init
(progn
@ -165,7 +163,6 @@
(defun version-control/init-git-gutter-fringe ()
(use-package git-gutter-fringe
:if (eq version-control-diff-tool 'git-gutter)
:defer t
:init
(progn
@ -222,7 +219,6 @@
(defun version-control/init-git-gutter-fringe+ ()
(use-package git-gutter-fringe+
:if (eq version-control-diff-tool 'git-gutter+)
:defer t
:init
(progn