Fix flicker when typing/moving cursor due to linum

This commit is contained in:
Wojciech Kozlowski 2017-08-28 22:19:58 +01:00
parent 15fac84de1
commit 1c6db3ede5
2 changed files with 22 additions and 3 deletions

View File

@ -28,10 +28,29 @@
;; --------------------------------------------------------------------------
;; Line numbers.
;;
;; Ideally, we could just use linum-format "%4d \u2502". However, the
;; unicode character for the vertical line causes the screen to flicker on
;; some screens when typing or moving the cursor. Using `nlinum' does not
;; solve the problem. A compromise is to instead use a whitespace character
;; of a different colour.
;;
;; Furthermore, since `linum' can struggle with large buffers, it is disabled
;; once the number of lines cannot fit into linum-format anymore. `nlinum'
;; is meant to solve the problem, but it updates line numbers after a visible
;; pause if a line is inderted/deleted.
;; --------------------------------------------------------------------------
(setq-default linum-format "%4d \u2502") ;; Line number format
(add-hook 'prog-mode-hook 'linum-mode) ;; Only in programming modes
(defun linum-format-func (line)
(concat
(propertize (format "%4d " line) 'face 'linum)
(propertize " " 'face 'mode-line-inactive)))
(setq-default linum-format 'linum-format-func)
(add-hook 'prog-mode-hook '(lambda ()
(unless (> (count-lines (point-min) (point-max))
9999)
(linum-mode))))
;; --------------------------------------------------------------------------
;; Formatting settings.

View File

@ -50,7 +50,7 @@
(*keywords* (if (eq variant 'dark) "#8AC6F2" "#A020F0"))
(*light-purple* (if (eq variant 'dark) "#FFCCFF" "#FFCCFF"))
(*line-number* (if (eq variant 'dark) "#2F577C" "#B3B3B3"))
(*line-number-bg* (if (eq variant 'dark) "#0A1721" "#FAFDFF"))
(*line-number-bg* (if (eq variant 'dark) "#071017" "#FAFDFF"))
(*mat* (if (eq variant 'dark) "#86DC2F" "#BA2F59"))
(*mb-prompt* (if (eq variant 'dark) "#8AC6F2" "#0000FF"))
(*method-declaration* (if (eq variant 'dark) "#AF81F4" "#0000FF"))