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

75 lines
2.1 KiB
EmacsLisp
Raw Normal View History

;;; git.el --- magit and stuff. -*- lexical-binding: t; -*-
2020-04-18 16:19:57 +02:00
;; Time-stamp: <2020-04-18T16:15:18+0200>
;;; Commentary:
;;; Code:
(require 'basics/package-management)
(require 'basics/global-variables)
;; Git integration.
(use-package git-commit
2020-04-18 03:12:10 +02:00
:defer 2)
(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
("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
:config
(add-to-list 'forge-alist '("schlomp.space" "schlomp.space/api/v1"
"schlomp.space" forge-gitea-repository))
)
) ; unless slow-computer.
2020-04-18 16:19:57 +02:00
;; Show VC status in fringe.
(use-package git-gutter
:bind ("C-c G" . git-gutter:popup-hunk) ; Popup current diff hunk.
:hook (prog-mode . git-gutter-mode))
(provide 'programming/git)
;;; git.el ends here