74 lines
2.6 KiB
EmacsLisp
74 lines
2.6 KiB
EmacsLisp
;; -*- lexical-binding: t; -*-
|
|
|
|
;; Magit!
|
|
(use-package magit
|
|
:commands (magit-status
|
|
magit-file-dispatch
|
|
magit-dispatch
|
|
magit-name-local-branch)
|
|
:init
|
|
(leader-def-key "g" '(nil :which-key "git"))
|
|
:config
|
|
(evil-collection-magit-setup)
|
|
(add-hook 'magit-mode-hook #'hl-line-mode)
|
|
:general
|
|
(leader-map "gs" #'magit-status
|
|
"gg" #'magit-file-dispatch
|
|
"gd" #'magit-dispatch))
|
|
|
|
;; Not strictly git-related, but with-editor is the part of Magit that
|
|
;; lets Emacs be the $EDITOR for shell commands
|
|
(use-package with-editor
|
|
:hook ((eshell-mode . with-editor-export-editor)
|
|
(shell-mode . with-editor-export-editor)
|
|
(vterm-mode . (lambda ()
|
|
(with-editor-export-editor)
|
|
(vterm-clear))))
|
|
:commands (with-editor-async-shell-command
|
|
with-editor-shell-command))
|
|
|
|
;; git-link makes it easy to copy the GitHub URL of the current file/line
|
|
(use-package git-link
|
|
:commands (git-link git-link-commit)
|
|
:init
|
|
(defun git-link-browse ()
|
|
(interactive)
|
|
(let ((git-link-open-in-browser t))
|
|
(call-interactively 'git-link)))
|
|
(defun git-link-browse-commit ()
|
|
(interactive)
|
|
(let ((git-link-open-in-browser t))
|
|
(call-interactively 'git-link-commit)))
|
|
:config
|
|
(add-to-list 'git-link-remote-alist '("git.jeremydormitzer.com" git-link-bitbucket))
|
|
(add-to-list 'git-link-commit-remote-alist '("git.jeremydormitzer.com" git-link-commit-bitbucket))
|
|
(add-to-list 'git-link-remote-alist '("ghe.spotify.net" git-link-github))
|
|
(add-to-list 'git-link-commit-remote-alist '("ghe.spotify.net" git-link-commit-github))
|
|
:general
|
|
(leader-map "gy" #'git-link
|
|
"gl" #'git-link-browse
|
|
"gc" #'git-link-commit
|
|
"gb" #'git-link-browse-commit))
|
|
|
|
;; Interact with GitHub etc. from Magit
|
|
(use-package forge
|
|
:after magit
|
|
:demand t
|
|
:config
|
|
(setq forge-add-default-bindings nil)
|
|
(evil-collection-forge-setup)
|
|
(add-to-list 'forge-alist '("git.jeremydormitzer.com"
|
|
"git.jeremydormitzer.com/api/v1"
|
|
"git.jeremydormitzer.com"
|
|
forge-gitea-repository))
|
|
(add-to-list 'forge-alist '("ghe.spotify.net"
|
|
"ghe.spotify.net/api/v3"
|
|
"ghe.spotify.net"
|
|
forge-github-repository))
|
|
:custom
|
|
(forge-owned-accounts '((jdormit . (remote-name "jdormit"))))
|
|
:general
|
|
(normal magit-mode-map "yu" #'forge-copy-url-at-point-as-kill))
|
|
|
|
(provide 'init-git)
|