init-vc.el (2994B)
1 ;;; init-vc.el --- version control -*- lexical-binding: t -*- 2 3 ;;; Commentary: 4 5 ;;; Code: 6 7 ;; magit 8 (my-use-package magit 9 :init 10 (defun my-magit-toggle-parent-section () 11 "Toggle parent magit section." 12 (interactive) 13 (magit-section-up) 14 (magit-section-toggle (magit-section-at))) 15 :config 16 (setq magit-bind-magit-project-status nil) 17 (unless *is-windows* 18 (setq magit-diff-refine-hunk 'all))) 19 20 ;; diff-hl 21 (my-use-package diff-hl 22 :hook 23 (diff-hl-mode . diff-hl-margin-mode) 24 (diff-hl-mode . global-diff-hl-show-hunk-mouse-mode) 25 (diff-hl-mode . diff-hl-flydiff-mode)) 26 27 ;; vc 28 (my-use-package vc 29 :straight nil 30 :commands vc-create-repo 31 :init 32 (defun my-vc-annotate-diff-current-revision () 33 "Show the diff of the revision displayed in this vc-annotate buffer 34 against its previous revision." 35 (interactive) 36 (if (not (derived-mode-p 'vc-annotate-mode)) 37 (message "Not a vc annotate buffer") 38 (let* ((file (caadr vc-buffer-overriding-fileset)) 39 (rev vc-buffer-revision) 40 (prev-rev 41 (let ((vc-use-short-revision vc-annotate-use-short-revision)) 42 (vc-call-backend vc-annotate-backend 'previous-revision file rev)))) 43 (if (not prev-rev) 44 (message "No previous revisions") 45 (vc-diff-internal vc-allow-async-diff 46 (list vc-annotate-backend (list file)) 47 prev-rev rev))))) 48 49 (defun my-vc-print-log-current-revision () 50 "Print the log of the revision displayed in this vc-annotate buffer." 51 (interactive) 52 (if (not (derived-mode-p 'vc-annotate-mode)) 53 (message "Not a vc annotate buffer") 54 (let* ((file (cadr vc-buffer-overriding-fileset)) 55 (rev vc-buffer-revision)) 56 (vc-print-log-internal vc-annotate-backend file rev t 1))))) 57 58 (my-use-package consult-vc 59 :straight 60 (consult-vc :type git 61 :repo "https://git.trogloxene.org/consult-vc.git") 62 :config 63 (setq consult-vc-annotate-revision-narrow-key-forward ?\] 64 consult-vc-annotate-revision-narrow-key-backward ?\[)) 65 66 ;; project 67 (my-use-package project 68 :straight nil 69 :autoload project-root 70 :config 71 (setq project-switch-commands (assq-delete-all 'project-vc-dir project-switch-commands)) 72 (setq project-switch-commands 73 (seq-uniq (append project-switch-commands 74 '((magit-project-status "Magit" ?v) 75 (ghostel-project "Ghostel" ?t) 76 (project-query-replace-regexp "Query Replace" ?q) 77 (consult-git-grep "Grep" ?g) 78 (consult-project-buffer "Buffers" ?b) 79 (project-ibuffer "Ibuffer" ?i) 80 (pilish "Pi" ?a)))))) 81 82 (my-use-package project-ibuffer 83 :straight 84 (project-ibuffer :type git 85 :repo "https://git.trogloxene.org/project-ibuffer.git")) 86 87 (provide 'init-vc) 88 ;;; init-vc.el ends here