115 lines
3.3 KiB
EmacsLisp
115 lines
3.3 KiB
EmacsLisp
;;; 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
|
||
:custom
|
||
(mc/insert-numbers-default 1)
|
||
(mc/always-run-for-all t)
|
||
:init
|
||
(setq mc/cmds-to-run-once
|
||
'(god-mode-all
|
||
hydra-multiple-cursors/body
|
||
hydra-multiple-cursors/mc/edit-lines
|
||
hydra-multiple-cursors/mc/insert-numbers
|
||
hydra-multiple-cursors/mc/mark-all-dwim
|
||
hydra-multiple-cursors/mc/mark-next-like-this
|
||
hydra-multiple-cursors/mc/mark-next-like-this-symbol
|
||
hydra-multiple-cursors/mc/mark-next-like-this-word
|
||
hydra-multiple-cursors/mc/mark-previous-like-this
|
||
hydra-multiple-cursors/mc/mark-previous-like-this-symbol
|
||
hydra-multiple-cursors/mc/mark-previous-like-this-word
|
||
hydra-multiple-cursors/mc/unmark-next-like-this
|
||
hydra-multiple-cursors/mc/unmark-previous-like-this
|
||
hydra-multiple-cursors/nil)))
|
||
|
||
;; crux,实用函数
|
||
(use-package crux)
|
||
|
||
;; hungry-delete,快速删除
|
||
(use-package hungry-delete)
|
||
|
||
;; drag-stuff,拖动字符
|
||
(use-package drag-stuff)
|
||
|
||
;; 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 (or *is-android* (not use-package-always-defer)) (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
|