Skip to content

Latest commit

 

History

History
211 lines (161 loc) · 4.48 KB

wal-vc.org

File metadata and controls

211 lines (161 loc) · 4.48 KB

Version Control

I’m becoming an old git. If you can no longer reconstruct history, use version control!

Header

;;; wal-vc.el --- Version control. -*- lexical-binding: t -*-

;;; Commentary:
;;
;; Provide version control packages.

;;; Code:

(eval-when-compile
  (require 'wal-useful nil t)
  (require 'wal-key-bindings nil t)
  (require 'wal-bridge nil t))

(declare-function magit-clone "ext:magit.el")
(declare-function wal-message-in-a-bottle "wal-useful.el")

Magit

Forget remembering git commands, use transient.

(junk-expand magit
  "Support pull requests and code reviews."
  :packages (forge code-review))

magit

Adds a transient with commands that make sense outside of a status buffer.

(use-package magit
  :wal-ways t

  :config
  (transient-define-prefix ma-magit ()
    "Call `magit' commands in a `magit'-y way."
    [["Creating"
      ("c" "clone" magit-clone)]

     ["Snapshotting"
      ("s" "status (quick)" magit-status-quick)]

     ["Branching"
      ("w" "worktree" magit-worktree)]

     ["Inspecting"
      ("l" "log" magit-log)
      ("d" "file" magit-diff-buffer-file)
      ("r" "range" magit-diff-range)]

     ["Debugging"
      ("b" "blame" magit-blame)]

     ["Magit"
      ("f" "find" magit-find-file)
      ("o" "find other window" magit-find-file-other-window)
      ("x" "run" magit-run)
      ("p" "process" magit-process-buffer)]])

  (wdb-nearby 'magit-process-mode :side 'bottom :height 10)

  (setq magit-process-finish-apply-ansi-colors t)

  :custom
  (magit-process-popup-time 10)

  :wal-bind
  (("m" . magit-status)
   ("M-m" . ma-magit))

  :custom
  (magit-blame-mode-lighter " mbl"))

Other

git-timemachine

If you want to go back in time and point fingers at the progenitors of doom. The toggle command is added to the custom transient for magit.

(use-package git-timemachine
  :config
  (transient-append-suffix 'ma-magit #'magit-clone
    '("t" "time machine" git-timemachine-toggle))

  :defer 2
  :after magit

  :delight " gtm")

git-modes

Add syntax highlighting for ignore files.

(use-package git-modes
  :mode (("/\\.npmignore\\'" . gitignore-mode)
         ("/\\.dockerignore" . gitignore-mode))

  :init
  (harpoon gitignore-mode
    :messages ("I don't think I know you")))

smerge-mode

When resolving conflicts, using ours and theirs should be easy. This adds a repeat map for smerge commands and sets to the command prefix to a more ergonomic binding.

(use-package smerge-mode
  :config
  (defvar-keymap smerge-repeat-map
    :doc "Keymap to repeat various `smerge' commands."
    :repeat t
    "n" 'smerge-next
    "p" 'smerge-prev
    "l" 'smerge-keep-lower
    "u" 'smerge-keep-upper
    "a" 'smerge-keep-all)

  :custom
  (smerge-command-prefix (kbd "C-c g"))

  :delight " smg")

diff-hl

Show diffs in the fringe (also in dired buffers).

(use-package diff-hl
  :defer 2
  :after magit

  :hook
  ((magit-post-refresh . diff-hl-magit-post-refresh)
   (magit-pre-refresh . diff-hl-magit-pre-refresh)
   (dired-mode . diff-hl-dired-mode))

  :config
  (global-diff-hl-mode)

  :bind
  (:map diff-hl-command-map
   ("*" . nil)
   ("[" . nil)
   ("]" . nil)
   ("{" . nil)
   ("}" . nil)
   ("n" . diff-hl-next-hunk)
   ("p" . diff-hl-previous-hunk)
   ("M-n" . diff-hl-show-hunk-next)
   ("M-p" . diff-hl-show-hunk-previous)
   ("r" . diff-hl-revert-hunk)
   ("s" . diff-hl-show-hunk))

  :general
  (ambassador :keymaps 'diff-hl-mode-map "h" '(:keymap diff-hl-command-map :wk "diff-hl"))

  :functions (global-diff-hl-mode))

Footer

(provide 'wal-vc)

;;; wal-vc.el ends here