.emacs.d/init.d/programming/git.el

81 lines
2.4 KiB
EmacsLisp
Raw Normal View History

;;; git.el --- magit and stuff. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-04-21T16:38:32+0200>
;;; Commentary:
;;; Code:
(require 'basics/package-management)
(require 'basics/global-variables)
;; Git integration.
(use-package git-commit
:defer 2
:config (defun my/set-git-commit-fill-column ()
(customize-set-variable 'fill-column 72))
:hook (git-commit-mode . my/set-git-commit-fill-column))
(unless slow-computer
(use-package magit
:custom
(magit-diff-refine-hunk 'all) ; Show word-granularity differences.
:config
;; <https://github.com/magit/magit/issues/4034>
(defun my/magit-display-buffer (buffer)
"Workaround to ensure that BUFFER is split vertically if necessary."
(if (and git-commit-mode
(with-current-buffer buffer
(derived-mode-p 'magit-diff-mode)))
(purpose--action-function buffer '((display-buffer-pop-up-window
display-buffer-use-some-window
display-buffer-below-selected)
(inhibit-same-window . t))))
(magit-display-buffer-traditional buffer))
(setq magit-display-buffer-function #'my/magit-display-buffer)
:bind
2020-04-21 16:35:42 +02:00
("C-x g" . nil) ; Disable default.
("C-c g" . magit-status)
("C-c M-g" . magit-dispatch)
:hook
(after-save . magit-after-save-refresh-status)
)
;; Use libgit rather than git.
(use-package magit-libgit)
;; Show TODOs in magit-status.
(use-package magit-todos
:after magit
:init
;; Mark variables as safe. This prevents prompts when using .dir-locals.el.
(put 'magit-todos-depth 'safe-local-variable #'integerp)
:hook
(magit-mode . magit-todos-mode)
)
;; Work with Git forges from Magit.
(use-package forge
:after magit
2020-04-20 21:27:46 +02:00
:config (add-to-list 'forge-alist
'("schlomp.space" "schlomp.space/api/v1"
"schlomp.space" forge-gitea-repository))
:hook (prog-mode . forge-bug-reference-setup))
) ; unless slow-computer.
2020-04-18 16:19:57 +02:00
;; Show VC status in fringe.
;; Not loading it automatically because it is slow.
2020-04-18 16:19:57 +02:00
(use-package git-gutter
:diminish git-gutter-mode
:bind (("C-c G" . git-gutter-mode)
("C-c M-G" . git-gutter:popup-hunk))) ; Popup diff hunk.
2020-04-18 16:19:57 +02:00
(provide 'programming/git)
;;; git.el ends here