refactor: Reorganize config with use-package and optimize startup hooks

- Split monolithic init-package.el into focused modules
- Convert eager `:init` blocks to lazy `:hook`
- Consolidate UI settings and defer theme loading.
- Remove duplicated config between GUI and terminal paths.
This commit is contained in:
2026-06-04 02:27:20 +08:00
parent 8db37d1c6d
commit b4733718d4
20 changed files with 910 additions and 849 deletions

100
lisp/init-edit.el Normal file
View File

@@ -0,0 +1,100 @@
;;; init-edit.el --- edit and navigate -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; delete select
(use-package delsel
:hook
(after-init . delete-selection-mode))
;; electric-pair补全括号
(use-package elec-pair
:config
(setq electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit
electric-pair-pairs (append '((?\~ . ?\~) (?\= . ?\=)) electric-pair-pairs)))
;; multiple-cursors
(use-package multiple-cursors
:config
(setq mc/insert-numbers-default 1))
;; crux实用函数
(use-package crux)
;; hungry-delete快速删除
(use-package hungry-delete)
;; drag-stuff拖动字符
(use-package drag-stuff)
;; mwim更聪明的beginning/end of line
(use-package mwim)
;; undo-fu撤回增强和跨会话历史
(use-package undo-fu
:config
(setq undo-in-region t
undo-fu-allow-undo-in-region t))
(use-package undo-fu-session
:hook
(after-init . undo-fu-session-global-mode))
;; vundo撤回树
(use-package vundo
:init
(setq undo-limit 800000
undo-strong-limit 1200000
undo-outer-limit 12000000))
;; expand-region快速展开选中
(use-package expand-region
:commands
(er/mark-symbol er/mark-word)
:config
(setq expand-region-smart-cursor t))
;; avy中文支持
(use-package ace-pinyin
:delight
:hook
(after-init . ace-pinyin-global-mode))
;; avy-zap
(use-package avy-zap
:bind
(("M-z" . avy-zap-to-char-dwim)
("M-Z" . avy-zap-up-to-char-dwim)))
;; god-mode模态编辑
(use-package god-mode
:init
(if *is-android* (add-hook 'after-init-hook 'god-mode-all))
:config
(unless *is-android* (which-key-enable-god-mode-support))
(setq god-mode-enable-function-key-translation nil
god-exempt-major-modes
(cl-union '(diff-mode exwm-mode) god-exempt-major-modes :test 'equal)
god-mode-lighter-string "THANK-GOD-MODE")
(defun my-sync-god-mode-lighter-face (&rest _)
(set-face-attribute 'god-mode-lighter nil
:inherit 'isearch-fail
:background (face-attribute 'mode-line :background nil t)
:weight 'bold))
(my-sync-god-mode-lighter-face)
(add-hook 'enable-theme-functions #'my-sync-god-mode-lighter-face)
(defun my-sync-line-numbers-with-god-mode ()
(let ((desired (if (bound-and-true-p god-local-mode)
'relative
t)))
(unless (or (eq display-line-numbers desired) (bound-and-true-p olivetti-mode))
(setq display-line-numbers desired))))
(add-hook 'post-command-hook #'my-sync-line-numbers-with-god-mode))
(provide 'init-edit)
;;; init-edit.el ends here