mirror of
http://github.com/JaeUs3792/dotfiles
synced 2025-12-13 23:51:34 +09:00
128 lines
3.9 KiB
EmacsLisp
128 lines
3.9 KiB
EmacsLisp
;;; init-edit.el -*- lexical-binding: t -*-
|
|
(require 'init-const)
|
|
(require 'init-funcs)
|
|
|
|
(use-package autorevert
|
|
:straight t
|
|
:ensure t
|
|
:diminish
|
|
:hook (after-init . global-auto-revert-mode))
|
|
(use-package avy
|
|
:straight t
|
|
:ensure t
|
|
:defer t
|
|
:hook (after-init . avy-setup-default)
|
|
:config
|
|
(setq avy-style 'de-bruijn
|
|
avy-all-windows t
|
|
avy-all-windows-alt nil
|
|
avy-background t))
|
|
;; Show number of matches in mode-line while searching
|
|
(use-package anzu
|
|
:straight t
|
|
:ensure t
|
|
:diminish
|
|
;;:bind (([remap query-replace] . anzu-query-replace)
|
|
;; ([remap query-replace-regexp] . anzu-query-replace-regexp)
|
|
;; :map isearch-mode-map
|
|
;; ([remap isearch-query-replace] . anzu-isearch-query-replace)
|
|
;; ([remap isearch-query-replace-regexp] . anzu-isearch-query-replace-regexp))
|
|
:hook (after-init . global-anzu-mode))
|
|
|
|
(use-package undo-tree
|
|
:straight t
|
|
:ensure t
|
|
:diminish
|
|
:hook (after-init . global-undo-tree-mode)
|
|
:custom
|
|
(undo-tree-history-directory-alist
|
|
`(("." . ,(expand-file-name (file-name-as-directory "undo-tree-hist")
|
|
user-emacs-directory))))
|
|
:config
|
|
(setq undo-tree-visualizer-diff t
|
|
undo-tree-visualizer-timestamps t
|
|
undo-tree-auto-save-history t
|
|
undo-tree-enable-undo-in-region t
|
|
undo-limit (* 800 1024)
|
|
undo-strong-limit (* 12 1024 1024)
|
|
undo-outer-limit (* 128 1024 1024)))
|
|
|
|
(use-package hideshow
|
|
:straight t
|
|
:ensure t
|
|
:diminish hs-minor-mode
|
|
:pretty-hydra
|
|
((:title (pretty-hydra-title "HideShow" 'octicon "nf-oct-fold")
|
|
:color amaranth :quit-key ("q" "C-g"))
|
|
("Fold"
|
|
(("t" hs-toggle-all "toggle all")
|
|
("a" hs-show-all "show all")
|
|
("i" hs-hide-all "hide all")
|
|
("g" hs-toggle-hiding "toggle hiding")
|
|
("c" hs-cycle "cycle block")
|
|
("s" hs-show-block "show block")
|
|
("h" hs-hide-block "hide block")
|
|
("l" hs-hide-level "hide level"))))
|
|
:bind ("C-~" . hideshow-hydra/body)
|
|
:hook (prog-mode . hs-minor-mode)
|
|
:config
|
|
;; More functions
|
|
;; @see https://karthinks.com/software/simple-folding-with-hideshow/
|
|
(defun hs-cycle (&optional level)
|
|
(interactive "p")
|
|
(let (message-log-max
|
|
(inhibit-message t))
|
|
(if (= level 1)
|
|
(pcase last-command
|
|
('hs-cycle
|
|
(hs-hide-level 1)
|
|
(setq this-command 'hs-cycle-children))
|
|
('hs-cycle-children
|
|
(save-excursion (hs-show-block))
|
|
(setq this-command 'hs-cycle-subtree))
|
|
('hs-cycle-subtree
|
|
(hs-hide-block))
|
|
(_
|
|
(if (not (hs-already-hidden-p))
|
|
(hs-hide-block)
|
|
(hs-hide-level 1)
|
|
(setq this-command 'hs-cycle-children))))
|
|
(hs-hide-level level)
|
|
(setq this-command 'hs-hide-level))))
|
|
|
|
(defun hs-toggle-all ()
|
|
"Toggle hide/show all."
|
|
(interactive)
|
|
(pcase last-command
|
|
('hs-toggle-all
|
|
(save-excursion (hs-show-all))
|
|
(setq this-command 'hs-global-show))
|
|
(_ (hs-hide-all))))
|
|
|
|
;; Display line counts
|
|
(defun hs-display-code-line-counts (ov)
|
|
"Display line counts when hiding codes."
|
|
(when (eq 'code (overlay-get ov 'hs))
|
|
(overlay-put ov 'display
|
|
(concat
|
|
" "
|
|
(propertize
|
|
(if (char-displayable-p ?⏷) "⏷" "...")
|
|
'face 'shadow)
|
|
(propertize
|
|
(format " (%d lines)"
|
|
(count-lines (overlay-start ov)
|
|
(overlay-end ov)))
|
|
'face '(:inherit shadow :height 0.8))
|
|
" "))))
|
|
(setq hs-set-up-overlay #'hs-display-code-line-counts))
|
|
|
|
;; Hanlde minified code
|
|
(use-package so-long
|
|
:straight t
|
|
:ensure t
|
|
:hook (after-init . global-so-long-mode))
|
|
|
|
(provide 'init-edit)
|
|
;;; init-edit.el ends here.
|