2020-01-27 02:11:10 +01:00
|
|
|
;;; git.el --- magit and stuff. -*- lexical-binding: t; -*-
|
|
|
|
|
2020-04-20 00:01:07 +02:00
|
|
|
;; Time-stamp: <2020-04-20T00:00:04+0200>
|
2020-01-27 02:11:10 +01:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2020-03-18 15:00:17 +01:00
|
|
|
(require 'basics/package-management)
|
2020-01-27 02:11:10 +01:00
|
|
|
(require 'basics/global-variables)
|
|
|
|
|
|
|
|
;; Git integration.
|
|
|
|
(use-package git-commit
|
2020-04-18 03:12:10 +02:00
|
|
|
:defer 2)
|
2020-01-27 02:11:10 +01:00
|
|
|
|
|
|
|
(unless slow-computer
|
|
|
|
(use-package magit
|
|
|
|
:custom
|
|
|
|
(magit-diff-refine-hunk 'all) ; Show word-granularity differences.
|
|
|
|
|
|
|
|
:config
|
2020-01-27 05:37:35 +01:00
|
|
|
;; <https://github.com/magit/magit/issues/4034>
|
2020-01-27 02:11:10 +01:00
|
|
|
(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)))
|
2020-01-27 05:37:35 +01:00
|
|
|
(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))
|
2020-01-27 02:11:10 +01:00
|
|
|
(setq magit-display-buffer-function #'my/magit-display-buffer)
|
|
|
|
|
|
|
|
:bind
|
2020-03-27 17:11:14 +01:00
|
|
|
("C-c g" . magit-status)
|
|
|
|
("C-c M-g" . magit-dispatch)
|
2020-01-27 02:11:10 +01:00
|
|
|
|
|
|
|
:hook
|
|
|
|
(after-save . magit-after-save-refresh-status)
|
|
|
|
)
|
|
|
|
|
|
|
|
;; Use libgit rather than git.
|
2020-04-10 14:17:47 +02:00
|
|
|
(use-package magit-libgit)
|
2020-01-27 02:11:10 +01:00
|
|
|
|
|
|
|
;; Show TODOs in magit-status.
|
|
|
|
(use-package magit-todos
|
|
|
|
:after magit
|
|
|
|
|
2020-04-10 14:06:21 +02:00
|
|
|
:init
|
2020-01-27 02:11:10 +01:00
|
|
|
;; 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.
|
2020-04-20 00:01:07 +02:00
|
|
|
:hook ((prog-mode . git-gutter-mode)
|
|
|
|
(text-mode . git-gutter-mode)))
|
2020-04-18 16:19:57 +02:00
|
|
|
|
2020-01-27 02:11:10 +01:00
|
|
|
(provide 'programming/git)
|
|
|
|
;;; git.el ends here
|