1.2 彩虹括号 rainbow-delimiters
;; [rainbow-delimiters] Highlight brackets according to their depth
(use-package rainbow-delimiters
:straight t
:hook ((prog-mode conf-mode yaml-mode) . rainbow-delimiters-mode)
:config
(setq rainbow-delimiters-max-face-count 5))
这个没啥好说的,开就完事了,大部分编辑器应该标配了。
1.3 highlight-parentheses
这个插件看上去会很像 show-paren-mode
,它们俩的区别在于 show-paren-mode
要求光标紧挨着括号,highlight-parentheses
没这个要求。
(use-package highlight-parentheses
:straight t
:hook ((minibuffer-setup . highlight-parentheses-minibuffer-setup)
(prog-mode . highlight-parentheses-mode))
:config
(setq highlight-parentheses-colors '("firebrick1" "firebrick3" "orange1" "orange3")
highlight-parentheses-attributes '((:underline t) (:underline t) (:underline t))
highlight-parentheses-delay 0.2)
)
在配置上,为了区分 show-paren-mode
,我给 highlight-parentheses
安排了鲜艳且温暖的配色(highlight-parentheses-colors
),同时给它们都加上了下划线的效果(highlight-parentheses-attributes
)。
同样出于性能考虑,这里设置了 0.2s
的延迟(highlight-parentheses-delay
)。0.2
是我摸索得到的最佳高亮延迟,既不会对性能造成影响,又不会让用户感受到明显拖沓。
效果展示
注意下面红色和橙色这块