83 lines
3.0 KiB
EmacsLisp
83 lines
3.0 KiB
EmacsLisp
;;; git.el --- magit and stuff. -*- lexical-binding: t; -*-
|
|
|
|
;;; Commentary:
|
|
|
|
;;; Code:
|
|
|
|
(require 'basics/package-management)
|
|
(require 'basics/global-variables)
|
|
(require 's)
|
|
|
|
;; Git integration.
|
|
(use-package git-commit
|
|
:defer 2
|
|
:config (defun my/set-git-commit-fill-column ()
|
|
(setq-local fill-column 72))
|
|
:hook (git-commit-mode . my/set-git-commit-fill-column))
|
|
|
|
(use-package magit
|
|
:unless slow-computer
|
|
:after (eldoc)
|
|
:custom ((magit-diff-refine-hunk 'all))
|
|
:config (progn
|
|
;; Didn't work in :custom.
|
|
(setq magit-process-finish-apply-ansi-colors t)
|
|
|
|
;; 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)
|
|
(s-chomp (buffer-string))))))
|
|
(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))
|
|
:bind (("C-x g" . nil) ; Disable default.
|
|
("C-c g" . magit-status)
|
|
("C-c M-g" . magit-dispatch)
|
|
(:map magit-hunk-section-map
|
|
("RET" . magit-diff-visit-worktree-file-other-window))
|
|
(:map magit-diff-mode-map
|
|
("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)))
|
|
:hook ((after-save . magit-after-save-refresh-status)
|
|
(magit-mode . keychain-refresh-environment)
|
|
(magit-status-mode . my/magit-eldoc-setup)
|
|
(magit-log-mode . my/magit-eldoc-setup)))
|
|
|
|
;; 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))
|
|
|
|
(provide 'programming/git)
|
|
;;; git.el ends here
|