mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-23 11:30:23 +10:00
Moving to Doom Emacs!
This commit is contained in:
8
.emacs.d/modules/emacs/vc/autoload/evil.el
Normal file
8
.emacs.d/modules/emacs/vc/autoload/evil.el
Normal file
@@ -0,0 +1,8 @@
|
||||
;;; emacs/vc/autoload/evil.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! :editor evil)
|
||||
|
||||
;;;###autoload (autoload '+vc:git-browse "emacs/vc/autoload/evil" nil t)
|
||||
(evil-define-command +vc:git-browse (bang)
|
||||
"Ex interface to `+vc/git-browse-region-or-line'."
|
||||
(interactive "<!>")
|
||||
(+vc/git-browse-region-or-line bang))
|
||||
41
.emacs.d/modules/emacs/vc/autoload/hydra.el
Normal file
41
.emacs.d/modules/emacs/vc/autoload/hydra.el
Normal file
@@ -0,0 +1,41 @@
|
||||
;;; emacs/vc/autoload/hydra.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! :ui hydra)
|
||||
|
||||
;;;###autoload (autoload '+vc/smerge-hydra/body "emacs/vc/autoload/hydra" nil t)
|
||||
(defhydra +vc/smerge-hydra (:hint nil
|
||||
:pre (if (not smerge-mode) (smerge-mode 1))
|
||||
;; Disable `smerge-mode' when quitting hydra if
|
||||
;; no merge conflicts remain.
|
||||
:post (smerge-auto-leave))
|
||||
"
|
||||
[smerge]
|
||||
Movement Keep Diff Other
|
||||
╭─────────────────────────────────────────────────────────╯
|
||||
^_g_^ [_b_] base [_<_] upper/base [_C_] Combine
|
||||
^_C-k_^ [_u_] upper [_=_] upper/lower [_r_] resolve
|
||||
^_k_ ↑^ [_l_] lower [_>_] base/lower [_R_] remove
|
||||
^_j_ ↓^ [_a_] all [_H_] hightlight
|
||||
^_C-j_^ [_RET_] current [_E_] ediff ╭──────────
|
||||
^_G_^ │ [_q_] quit
|
||||
"
|
||||
("g" (progn (goto-char (point-min)) (smerge-next)))
|
||||
("G" (progn (goto-char (point-max)) (smerge-prev)))
|
||||
("C-j" smerge-next)
|
||||
("C-k" smerge-prev)
|
||||
("j" next-line)
|
||||
("k" previous-line)
|
||||
("b" smerge-keep-base)
|
||||
("u" smerge-keep-upper)
|
||||
("l" smerge-keep-lower)
|
||||
("a" smerge-keep-all)
|
||||
("RET" smerge-keep-current)
|
||||
("\C-m" smerge-keep-current)
|
||||
("<" smerge-diff-base-upper)
|
||||
("=" smerge-diff-upper-lower)
|
||||
(">" smerge-diff-base-lower)
|
||||
("H" smerge-refine)
|
||||
("E" smerge-ediff)
|
||||
("C" smerge-combine-with-next)
|
||||
("r" smerge-resolve)
|
||||
("R" smerge-kill-current)
|
||||
("q" nil :color blue))
|
||||
43
.emacs.d/modules/emacs/vc/autoload/vc.el
Normal file
43
.emacs.d/modules/emacs/vc/autoload/vc.el
Normal file
@@ -0,0 +1,43 @@
|
||||
;;; emacs/vc/autoload/vc.el -*- lexical-binding: t; -*-
|
||||
|
||||
(autoload 'browse-at-remote--file-url "browse-at-remote")
|
||||
|
||||
;;;###autoload
|
||||
(defun +vc/browse-at-remote-file-or-region ()
|
||||
"Open the current file at remote in your browser.
|
||||
If a selection is active, highlight them. Otherwise omits the #L<N> suffix in
|
||||
the URL."
|
||||
(interactive)
|
||||
(if (or (use-region-p)
|
||||
(ignore-errors (evil-visual-state-p)))
|
||||
(browse-at-remote)
|
||||
(browse-url (browse-at-remote--file-url (buffer-file-name)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vc/browse-at-remote-kill-file-or-region ()
|
||||
"Copy the current file's remote URL to your clipboard.
|
||||
If a selection is active, highlight them. Otherwise omits the #L<N> suffix in
|
||||
the URL."
|
||||
(interactive)
|
||||
(if (or (use-region-p)
|
||||
(ignore-errors (evil-visual-state-p)))
|
||||
(browse-at-remote-kill)
|
||||
(kill-new (browse-at-remote--file-url (buffer-file-name)))))
|
||||
|
||||
|
||||
(defun +vc--remote-homepage ()
|
||||
(or (let ((url (browse-at-remote--remote-ref)))
|
||||
(cdr (browse-at-remote--get-url-from-remote (car url))))
|
||||
(user-error "Can't find homepage for current project")))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vc/browse-at-remote-homepage ()
|
||||
"Open homepage for current project in browser."
|
||||
(interactive)
|
||||
(browse-url (+vc--remote-homepage)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +vc/browse-at-remote-kill-homepage ()
|
||||
"Copy homepage URL of current project to clipboard."
|
||||
(interactive)
|
||||
(kill-new (+vc--remote-homepage)))
|
||||
73
.emacs.d/modules/emacs/vc/config.el
Normal file
73
.emacs.d/modules/emacs/vc/config.el
Normal file
@@ -0,0 +1,73 @@
|
||||
;;; emacs/vc/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(when IS-WINDOWS
|
||||
(setenv "GIT_ASKPASS" "git-gui--askpass"))
|
||||
|
||||
|
||||
(after! vc-annotate
|
||||
(set-popup-rules!
|
||||
'(("^\\vc-d" :select nil) ; *vc-diff*
|
||||
("^\\vc-c" :select t))) ; *vc-change-log*
|
||||
(set-evil-initial-state!
|
||||
'(vc-annotate-mode vc-git-log-view-mode)
|
||||
'normal)
|
||||
|
||||
;; Clean up after itself
|
||||
(define-key vc-annotate-mode-map [remap quit-window] #'kill-current-buffer))
|
||||
|
||||
|
||||
(after! git-timemachine
|
||||
;; Sometimes I forget `git-timemachine' is enabled in a buffer, so instead of
|
||||
;; showing revision details in the minibuffer, show them in
|
||||
;; `header-line-format', which has better visibility.
|
||||
(setq git-timemachine-show-minibuffer-details t)
|
||||
|
||||
(defadvice! +vc-update-header-line-a (revision)
|
||||
"Show revision details in the header-line, instead of the minibuffer.
|
||||
|
||||
Sometimes I forget `git-timemachine' is enabled in a buffer. Putting revision
|
||||
info in the `header-line-format' is a good indication."
|
||||
:override #'git-timemachine--show-minibuffer-details
|
||||
(let* ((date-relative (nth 3 revision))
|
||||
(date-full (nth 4 revision))
|
||||
(author (if git-timemachine-show-author (concat (nth 6 revision) ": ") ""))
|
||||
(sha-or-subject (if (eq git-timemachine-minibuffer-detail 'commit) (car revision) (nth 5 revision))))
|
||||
(setq header-line-format
|
||||
(format "%s%s [%s (%s)]"
|
||||
(propertize author 'face 'git-timemachine-minibuffer-author-face)
|
||||
(propertize sha-or-subject 'face 'git-timemachine-minibuffer-detail-face)
|
||||
date-full date-relative))))
|
||||
|
||||
(after! evil
|
||||
;; rehash evil keybindings so they are recognized
|
||||
(add-hook 'git-timemachine-mode-hook #'evil-normalize-keymaps))
|
||||
|
||||
(when (featurep! :tools magit)
|
||||
(add-transient-hook! #'git-timemachine-blame (require 'magit-blame)))
|
||||
|
||||
(map! :map git-timemachine-mode-map
|
||||
:n "C-p" #'git-timemachine-show-previous-revision
|
||||
:n "C-n" #'git-timemachine-show-next-revision
|
||||
:n "gb" #'git-timemachine-blame
|
||||
:n "gtc" #'git-timemachine-show-commit))
|
||||
|
||||
|
||||
(use-package! git-commit
|
||||
:after-call after-find-file
|
||||
:config
|
||||
(global-git-commit-mode +1)
|
||||
(set-yas-minor-mode! 'git-commit-mode)
|
||||
|
||||
;; Enforce git commit conventions.
|
||||
;; See https://chris.beams.io/posts/git-commit/
|
||||
(setq git-commit-summary-max-length 50
|
||||
git-commit-style-convention-checks '(overlong-summary-line non-empty-second-line))
|
||||
(setq-hook! 'git-commit-mode-hook fill-column 72)
|
||||
|
||||
(add-hook! 'git-commit-setup-hook
|
||||
(defun +vc-start-in-insert-state-maybe-h ()
|
||||
"Start git-commit-mode in insert state if in a blank commit message,
|
||||
otherwise in default state."
|
||||
(when (and (bound-and-true-p evil-mode)
|
||||
(bobp) (eolp))
|
||||
(evil-insert-state)))))
|
||||
11
.emacs.d/modules/emacs/vc/packages.el
Normal file
11
.emacs.d/modules/emacs/vc/packages.el
Normal file
@@ -0,0 +1,11 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; emacs/vc/packages.el
|
||||
|
||||
(package! vc :built-in t)
|
||||
(package! vc-annotate :built-in t)
|
||||
(package! smerge-mode :built-in t)
|
||||
|
||||
(package! browse-at-remote)
|
||||
(package! git-timemachine)
|
||||
(package! gitconfig-mode)
|
||||
(package! gitignore-mode)
|
||||
Reference in New Issue
Block a user