~cytrogen/.emacs.d

53c8cc88cc5eb87f4ca5610e5767eba4f12734ac — Cytrogen a month ago 5e25bc7
feat(git): 添加 Magit、diff-hl、git-timemachine、ibuffer-vc

- Magit 通过 project-prefix-map(C-x p m)启动
- Diff-hl 边栏显示增删改标记,集成 dired 和 magit 刷新
- Git-timemachine 逐版本浏览文件历史
- Ibuffer-vc 按版本控制项目分组 buffer(C-x C-b)
1 files changed, 41 insertions(+), 0 deletions(-)

A config/pkg-git.el
A config/pkg-git.el => config/pkg-git.el +41 -0
@@ 0,0 1,41 @@
;;; pkg-git.el --- Git integration -*- lexical-binding: t -*-

;; Copyright (C) 2026 Cytrogen

;; Many package selections and configurations adapted from
;; Steve Purcell's emacs.d: https://github.com/purcell/emacs.d

;;; Code:

;; Magit — Git 完整操作界面
(unless (package-installed-p 'magit)
  (package-refresh-contents)
  (package-install 'magit))

;; 绑定 C-x p m — magit-project-status 已由 magit autoloads 注册
(keymap-set project-prefix-map "m" #'magit-project-status)

;; Diff-hl — 边栏显示 git 增删改
(unless (package-installed-p 'diff-hl)
  (package-install 'diff-hl))
(require 'diff-hl)
(global-diff-hl-mode 1)
(add-hook 'dired-mode-hook 'diff-hl-dired-mode)
(add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)

;; Git-timemachine — 逐版本浏览文件历史
(unless (package-installed-p 'git-timemachine)
  (package-install 'git-timemachine))

;; Ibuffer-vc — ibuffer 按版本控制项目分组
(unless (package-installed-p 'ibuffer-vc)
  (package-install 'ibuffer-vc))
(global-set-key (kbd "C-x C-b") 'ibuffer)
(add-hook 'ibuffer-hook
          (lambda ()
            (ibuffer-vc-set-filter-groups-by-vc-root)
            (unless (eq ibuffer-sorting-mode 'alphabetic)
              (ibuffer-do-sort-by-alphabetic))))

(provide 'pkg-git)
;;; pkg-git.el ends here