2020-01-27 02:11:10 +01:00
|
|
|
;;; git.el --- magit and stuff. -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;;; 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)
|
2021-06-22 02:03:44 +02:00
|
|
|
(require 's)
|
2020-01-27 02:11:10 +01:00
|
|
|
|
|
|
|
;; Git integration.
|
|
|
|
(use-package git-commit
|
2020-04-20 21:28:19 +02:00
|
|
|
:defer 2
|
|
|
|
:config (defun my/set-git-commit-fill-column ()
|
2020-04-22 03:17:44 +02:00
|
|
|
(setq-local fill-column 72))
|
2020-04-20 21:28:19 +02:00
|
|
|
:hook (git-commit-mode . my/set-git-commit-fill-column))
|
2020-01-27 02:11:10 +01:00
|
|
|
|
2020-12-08 13:17:06 +01:00
|
|
|
(use-package magit
|
|
|
|
:unless slow-computer
|
2021-07-16 16:50:03 +02:00
|
|
|
:after (eldoc)
|
2021-12-24 16:55:00 +01:00
|
|
|
:defer 4
|
2021-07-27 21:05:29 +02:00
|
|
|
:custom ((magit-diff-refine-hunk 'all))
|
2021-06-21 23:46:50 +02:00
|
|
|
:config (progn
|
2021-07-27 21:05:29 +02:00
|
|
|
;; Didn't work in :custom.
|
|
|
|
(setq magit-process-finish-apply-ansi-colors t)
|
|
|
|
|
2021-06-21 23:46:50 +02:00
|
|
|
;; https://tsdh.org/posts/2021-06-21-using-eldoc-with-magit.html
|
|
|
|
(defun my/magit-eldoc-for-commit ()
|
|
|
|
(let ((commit (magit-commit-at-point)))
|
|
|
|
(when commit
|
|
|
|
(with-temp-buffer
|
|
|
|
(magit-git-insert "show"
|
|
|
|
"--format=format:%an <%ae>, %ai (%ar)%n%b"
|
|
|
|
(format "--stat=%d" (window-width))
|
|
|
|
commit)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(put-text-property (point-min)
|
|
|
|
(line-end-position)
|
|
|
|
'face 'bold)
|
2021-06-22 02:03:44 +02:00
|
|
|
(s-chomp (buffer-string))))))
|
2021-06-21 23:46:50 +02:00
|
|
|
(defun my/magit-eldoc-setup ()
|
|
|
|
(add-function :before-until (local 'eldoc-documentation-function)
|
|
|
|
#'my/magit-eldoc-for-commit)
|
|
|
|
(eldoc-mode 1))
|
|
|
|
|
|
|
|
(eldoc-add-command 'magit-next-line)
|
|
|
|
(eldoc-add-command 'magit-previous-line))
|
2021-06-19 08:37:56 +02:00
|
|
|
:bind (("C-x g" . nil) ; Disable default.
|
2020-12-08 13:17:06 +01:00
|
|
|
("C-c g" . magit-status)
|
|
|
|
("C-c M-g" . magit-dispatch)
|
|
|
|
(:map magit-hunk-section-map
|
2021-04-23 20:58:25 +02:00
|
|
|
("RET" . magit-diff-visit-worktree-file-other-window))
|
|
|
|
(:map magit-diff-mode-map
|
2021-06-01 15:30:42 +02:00
|
|
|
("C-<down>" . magit-section-forward-sibling)
|
|
|
|
("C-<up>" . magit-section-backward-sibling))
|
|
|
|
(:map magit-status-mode-map
|
|
|
|
("C-<down>" . magit-section-forward-sibling)
|
|
|
|
("C-<up>" . magit-section-backward-sibling)))
|
2020-12-08 13:17:06 +01:00
|
|
|
:hook ((after-save . magit-after-save-refresh-status)
|
2021-06-21 23:46:50 +02:00
|
|
|
(magit-mode . keychain-refresh-environment)
|
|
|
|
(magit-status-mode . my/magit-eldoc-setup)
|
|
|
|
(magit-log-mode . my/magit-eldoc-setup)))
|
2020-12-08 13:17:06 +01:00
|
|
|
|
|
|
|
;; Use libgit rather than git.
|
|
|
|
(use-package magit-libgit
|
|
|
|
:after (magit))
|
|
|
|
|
|
|
|
;; Show TODOs in magit-status.
|
|
|
|
(use-package magit-todos
|
|
|
|
:after (magit)
|
|
|
|
:init (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))
|
|
|
|
:hook (prog-mode . forge-bug-reference-setup))
|
2020-01-27 02:11:10 +01:00
|
|
|
|
2021-11-27 16:12:21 +01:00
|
|
|
(use-package blamer)
|
2021-10-28 21:46:16 +02:00
|
|
|
|
2020-01-27 02:11:10 +01:00
|
|
|
(provide 'programming/git)
|
|
|
|
;;; git.el ends here
|