如题如图
起初发现 nlinum 的高亮是高亮行号,那应该有地方修改样式,翻了代码找了好久终于找到这个函数(大佬勿喷),然后拿出来自定义,就有了上面的效果。
和大伙分享这份简单的喜悦 。
代码
(leaf nlinum
:hook ((org-mode-hook . nlinum-mode)
(prog-mode-hook . nlinum-mode))
:config
(setq nlinum-highlight-current-line t)
(defconst my-nlinum-format-function
(lambda (line width)
(let* ((is-current-line (= line nlinum--current-line))
(str (format nlinum-format line)))
;; use -> as current line
;; or change to any symbol you like
;; here
(and is-current-line (setq str "->"))
(when (< (length str) width)
;; Left pad to try and right-align the line-numbers.
(setq str (concat (make-string (- width (length str)) ?\ ) str)))
(put-text-property 0 width 'face
(if (and nlinum-highlight-current-line
is-current-line)
'nlinum-current-line
'linum)
str)
str)))
;;take effect
(setq nlinum-format-function my-nlinum-format-function))
效果是这样的
如果觉得突兀 还可以类似下面这样,使得 “->” 跟着 行的数字 一起变长
;; use -> as current line
;; or change to any symbol you like
;; here
;; (and is-current-line (setq str "->"))
(when is-current-line
(let* ((ms "->")
(es "-")
(el (- (length str) (length ms))))
(while (> el 0)
(setq ms (concat es ms))
(setq el (1- el)))
(setq str ms)))