forgot to add emacs modules dir
This commit is contained in:
parent
0e37266a43
commit
b7a32b5077
|
@ -0,0 +1,101 @@
|
|||
;;; init-highlight.el --- Highlighting stuff
|
||||
;;; Commentary:
|
||||
;; Highlighting symbols, indentation, brackets, todo
|
||||
|
||||
;;; Code:
|
||||
|
||||
;; TODO: do I need hl-line package??
|
||||
|
||||
;; Highlight indentions
|
||||
(use-package highlight-indent-guides
|
||||
:straight t
|
||||
:diminish
|
||||
:hook ((prog-mode yaml-mode) . highlight-indent-guides-mode)
|
||||
:init (setq highlight-indent-guides-method 'character
|
||||
highlight-indent-guides-responsive 'top
|
||||
highlight-indent-guides-suppress-auto-error t)
|
||||
:config
|
||||
(with-no-warnings
|
||||
;; Don't display first level of indentation
|
||||
(defun my-indent-guides-for-all-but-first-column (level responsive display)
|
||||
(unless (< level 1)
|
||||
(highlight-indent-guides--highlighter-default level responsive display)))
|
||||
(setq highlight-indent-guides-highlighter-function
|
||||
#'my-indent-guides-for-all-but-first-column)
|
||||
|
||||
;; Disable in `macrostep' expanding
|
||||
(with-eval-after-load 'macrostep
|
||||
(advice-add #'macrostep-expand
|
||||
:after (lambda (&rest _)
|
||||
(when highlight-indent-guides-mode
|
||||
(highlight-indent-guides-mode -1))))
|
||||
(advice-add #'macrostep-collapse
|
||||
:after (lambda (&rest _)
|
||||
(when (derived-mode-p 'prog-mode 'yaml-mode)
|
||||
(highlight-indent-guides-mode 1)))))
|
||||
|
||||
;; Don't display indentations in `swiper'
|
||||
;; https://github.com/DarthFennec/highlight-indent-guides/issues/40
|
||||
(with-eval-after-load 'ivy
|
||||
(defun my-ivy-cleanup-indentation (str)
|
||||
"Clean up indentation highlighting in ivy minibuffer."
|
||||
(let ((pos 0)
|
||||
(next 0)
|
||||
(limit (length str))
|
||||
(prop 'highlight-indent-guides-prop))
|
||||
(while (and pos next)
|
||||
(setq next (text-property-not-all pos limit prop nil str))
|
||||
(when next
|
||||
(setq pos (text-property-any next limit prop nil str))
|
||||
(ignore-errors
|
||||
(remove-text-properties next pos '(display nil face nil) str))))))
|
||||
(advice-add #'ivy-cleanup-string :after #'my-ivy-cleanup-indentation))))
|
||||
|
||||
|
||||
;; Colorize color names in buffers
|
||||
(use-package rainbow-mode
|
||||
:straight t
|
||||
:diminish
|
||||
:bind (:map special-mode-map
|
||||
("w" . rainbow-mode))
|
||||
:hook ((html-mode php-mode) . rainbow-mode)
|
||||
:config
|
||||
(with-no-warnings
|
||||
;; HACK: Use overlay instead of text properties to override `hl-line' faces.
|
||||
;; @see https://emacs.stackexchange.com/questions/36420
|
||||
(defun my-rainbow-colorize-match (color &optional match)
|
||||
(let* ((match (or match 0))
|
||||
(ov (make-overlay (match-beginning match) (match-end match))))
|
||||
(overlay-put ov 'ovrainbow t)
|
||||
(overlay-put ov 'face `((:foreground ,(if (> 0.5 (rainbow-x-color-luminance color))
|
||||
"white" "black"))
|
||||
(:background ,color)))))
|
||||
(advice-add #'rainbow-colorize-match :override #'my-rainbow-colorize-match)
|
||||
|
||||
(defun my-rainbow-clear-overlays ()
|
||||
"Clear all rainbow overlays."
|
||||
(remove-overlays (point-min) (point-max) 'ovrainbow t))
|
||||
(advice-add #'rainbow-turn-off :after #'my-rainbow-clear-overlays)))
|
||||
|
||||
;; Highlight brackets according to their depth
|
||||
(use-package rainbow-delimiters
|
||||
:straight t
|
||||
:hook (prog-mode . rainbow-delimiters-mode))
|
||||
|
||||
;; Highlight TODO and similar keywords in comments and strings
|
||||
(use-package hl-todo
|
||||
:straight t
|
||||
:bind (:map hl-todo-mode-map
|
||||
([C-f3] . hl-todo-occur)
|
||||
("C-c t p" . hl-todo-previous)
|
||||
("C-c t n" . hl-todo-next)
|
||||
("C-c t o" . hl-todo-occur))
|
||||
:hook (after-init . global-hl-todo-mode)
|
||||
:config
|
||||
(dolist (keyword '("BUG" "DEFECT" "ISSUE"))
|
||||
(cl-pushnew `(,keyword . ,(face-foreground 'error)) hl-todo-keyword-faces))
|
||||
(dolist (keyword '("WORKAROUND" "HACK" "TRICK"))
|
||||
(cl-pushnew `(,keyword . ,(face-foreground 'warning)) hl-todo-keyword-faces)))
|
||||
|
||||
(provide 'init-highlight)
|
||||
;;; init-highlight.el ends here
|
Loading…
Reference in New Issue